Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AllCops:
NewCops: enable

Metrics/BlockLength:
IgnoredMethods: ['describe']
AllowedMethods: ['describe']

Style/Documentation:
Enabled: false
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Unreleased
* Add a command line tool `gmi2html`

v0.2.0
* Group consecutive links under single paragraph tag
* Remove spec and hidden files from built gem
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ html_string = File.open('capsule/my_gemtext.gmi', 'r') do |f|
end
```

There is also a command line tool called `gmi2html`.
Please refer to the help message (`gmi2html --help`) for its usage.

## Status

Second release but should be feature complete
Expand Down
29 changes: 29 additions & 0 deletions exe/gmi2html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'gmi2html'
require 'optparse'

input = $stdin unless $stdin.tty?
output = $stdout

parser = OptionParser.new
parser.on('-o', '--output=PATH', 'Output HTML path. Standard output is used by default.') do |path|
output = File.open(path, 'w')
end
parser.on('-i', '--input=PATH', 'Input Gemtext path. Standard input is used by default.') do |path|
input = File.open(path)
end
parser.parse!

unless input
warn 'No input provided. Please specify input path or use stdin.'
puts parser
exit 1
end

html = Gmi2html::Document.new(input).to_html
input.close

output.write(html)
output.close
10 changes: 5 additions & 5 deletions gmi2html.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'

gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).reject do |f|
f.match(%r{^(\.|spec)})
end
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
f.match(%r{^(\.|spec)})
end
gem.bindir = 'exe'
gem.executables = gem.files.grep(%r{^exe/}).map { |f| File.basename(f) }
gem.require_paths = %w[lib]
gem.required_ruby_version = '>= 2.5.0'

gem.metadata = {
'homepage_uri' => 'https://github.com/jebw/gmi2html/',
'changelog_uri' => 'https://github.com/jebw/gmi2html/blob/main/CHANGELOG.md',
'source_code_uri' => 'https://github.com/jebw/gmi2html/',
'documentation_uri' => "https://github.com/jebw/gmi2html/blob/main/README.md",
'documentation_uri' => 'https://github.com/jebw/gmi2html/blob/main/README.md',
'bug_tracker_uri' => 'https://github.com/jebw/gmi2html/issues',
'rubygems_mfa_required' => 'true'
}
Expand Down
2 changes: 1 addition & 1 deletion spec/gmi2html/node_renderers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def tag
let(:instance) { described_class.for_gemtext node }

it 'will return a Gmi2html::NodeRenderers::Text' do
expect(instance).to be_kind_of Gmi2html::NodeRenderers::Text
expect(instance).to be_a Gmi2html::NodeRenderers::Text
end

it 'will assign the content' do
Expand Down
3 changes: 3 additions & 0 deletions spec/gmi2html/node_renderers/link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
let(:link) { Gemtext::Link.new '/my-capsule my capsule' }

context 'when only link' do
let(:prev_node) { nil }
let(:next_node) { nil }

it 'will render opening and closing p tags in addition to the a tag' do
expect(rendered).to eql \
%(<p>\n<a href="/my-capsule">my capsule</a>\n</p>\n)
Expand Down
2 changes: 1 addition & 1 deletion spec/gmi2html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
describe 'VERSION' do
subject { described_class::VERSION }

it { is_expected.to eql '0.1.0' }
it { is_expected.to eql '0.2.0' }
end
end