gmi2html 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae673cf5c85980e03af885f8da0c40ed224fbac8eac0fdc5fb7d83695ed30d7c
4
- data.tar.gz: 790e59d74edf8769df5ebd6551245417539536c3308626429a87415d506a6b4d
3
+ metadata.gz: 7f21a04e45e6fddd82e7f5b4000b504cb4b9b241514bde8f27ae3d40bda33d42
4
+ data.tar.gz: 0331d6c2cae8da1b1e670463a18c8ae67ac7a41a5ec5204dd95e8a578147e058
5
5
  SHA512:
6
- metadata.gz: e9160a96d69dc21b3a9a9918ab0438889e5ab07d9e93dec730a01f0103de781918d2d92de52f82c3d116565302ef7b3773e85db24f174e0a5da2f365e77e12a1
7
- data.tar.gz: f3cf8b3d11b3e5190fdc86727262549f366fd7d676757949dd2e6fae7aeb46cbfaaf80d024a60e9e058f039bd8bd2e541e85dc740e9791faffae7d1b9b093c0c
6
+ metadata.gz: 1a8fd2936bfa0581246f08d89669ff8a9461692263ba2b3e71f0dc47d94f7de2a5ec4ac5362dafaf95589d87facf464f728ebf8b6354e9cfcaeae781b791e1d3
7
+ data.tar.gz: de900159e29c7cc27d2f0ce593f8a54ba1b5845aa0b02eaa53aead0ed1b37b9c771ca04529413549ec81cf8b2adb61cfea0791d9b2521ddcd362b41161cf70cb
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ v0.2.0
2
+ * Group consecutive links under single paragraph tag
3
+ * Remove spec and hidden files from built gem
4
+
5
+ v0.1.0
6
+ * Initial release
@@ -8,14 +8,16 @@ Gemtext is a simple plain text format, similar to Markdown but simpler. It is th
8
8
 
9
9
  For more information on Gemini see the official page
10
10
 
11
- => //gemini.circumlunar.space Gemini official page
12
- => //gemini.circumlunar.space/docs/specification.gmi Gemini specification
11
+ [Gemini official page](//gemini.circumlunar.space)
12
+ [Gemini specification](//gemini.circumlunar.space/docs/specification.gmi)
13
+
14
+ I've written a separate gem - [jekyll-gemini](https://github.com/jebw/jekyll-gemini) which uses this gem for publishing from your Jekyll blog to a Gemini capsule.
13
15
 
14
16
  ## Using Gmi2html
15
17
 
16
18
  To convert a Gemtext string to an html string
17
19
 
18
- ```
20
+ ```ruby
19
21
  require 'gmi2html'
20
22
 
21
23
  html_string = Gmi2html::Document.new(my_gemtext_string).to_html
@@ -23,7 +25,7 @@ html_string = Gmi2html::Document.new(my_gemtext_string).to_html
23
25
 
24
26
  To convert a Gemtext file to an html string
25
27
 
26
- ```
28
+ ```ruby
27
29
  require 'gmi2html'
28
30
 
29
31
  html_string = File.open('capsule/my_gemtext.gmi', 'r') do |f|
@@ -33,7 +35,7 @@ end
33
35
 
34
36
  ## Status
35
37
 
36
- First release but should be feature complete
38
+ Second release but should be feature complete
37
39
 
38
40
  ### Supported
39
41
 
data/gmi2html.gemspec CHANGED
@@ -16,12 +16,23 @@ Gem::Specification.new do |gem|
16
16
  gem.homepage = 'https://github.com/jebw/gmi2html'
17
17
  gem.license = 'MIT'
18
18
 
19
- gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).reject do |f|
20
+ f.match(%r{^(\.|spec)})
21
+ end
20
22
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
21
23
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
24
  gem.require_paths = %w[lib]
23
25
  gem.required_ruby_version = '>= 2.5.0'
24
26
 
27
+ gem.metadata = {
28
+ 'homepage_uri' => 'https://github.com/jebw/gmi2html/',
29
+ 'changelog_uri' => 'https://github.com/jebw/gmi2html/blob/main/CHANGELOG.md',
30
+ 'source_code_uri' => 'https://github.com/jebw/gmi2html/',
31
+ 'documentation_uri' => "https://github.com/jebw/gmi2html/blob/main/README.md",
32
+ 'bug_tracker_uri' => 'https://github.com/jebw/gmi2html/issues',
33
+ 'rubygems_mfa_required' => 'true'
34
+ }
35
+
25
36
  gem.add_dependency 'gemtext', '~> 1.0'
26
37
 
27
38
  gem.add_development_dependency 'bundler', '~> 2.2'
@@ -23,9 +23,9 @@ module Gmi2html
23
23
  %(<#{tag} href="#{escaped_link}">#{escaped_description}</#{tag}>\n)
24
24
  end
25
25
 
26
- def render(_prev_node = nil, _next_node = nil)
27
- prefix = "<#{wrapping_tag}>\n"
28
- suffix = "</#{wrapping_tag}>\n"
26
+ def render(prev_node = nil, next_node = nil)
27
+ prefix = prev_node.is_a?(Gemtext::Link) ? '' : "<#{wrapping_tag}>\n"
28
+ suffix = next_node.is_a?(Gemtext::Link) ? '' : "</#{wrapping_tag}>\n"
29
29
 
30
30
  "#{prefix}#{rendered_link_tag}#{suffix}"
31
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gmi2html
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmi2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Wilkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-17 00:00:00.000000000 Z
11
+ date: 2022-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemtext
@@ -159,14 +159,10 @@ executables: []
159
159
  extensions: []
160
160
  extra_rdoc_files: []
161
161
  files:
162
- - ".editorconfig"
163
- - ".gitignore"
164
- - ".rubocop.yml"
165
- - ".ruby-version"
166
- - ".yardoopts"
162
+ - CHANGELOG.md
167
163
  - Gemfile
168
164
  - LICENSE.txt
169
- - README.gmi
165
+ - README.md
170
166
  - Rakefile
171
167
  - gmi2html.gemspec
172
168
  - lib/gmi2html.rb
@@ -184,28 +180,16 @@ files:
184
180
  - lib/gmi2html/node_renderers/whitespace.rb
185
181
  - lib/gmi2html/renderer.rb
186
182
  - lib/gmi2html/version.rb
187
- - spec/fixtures/complex.gmi
188
- - spec/fixtures/complex.html
189
- - spec/fixtures/simple.gmi
190
- - spec/fixtures/simple.html
191
- - spec/gmi2html/document_spec.rb
192
- - spec/gmi2html/node_renderers/base_spec.rb
193
- - spec/gmi2html/node_renderers/heading_spec.rb
194
- - spec/gmi2html/node_renderers/link_spec.rb
195
- - spec/gmi2html/node_renderers/list_item_spec.rb
196
- - spec/gmi2html/node_renderers/preformatted_spec.rb
197
- - spec/gmi2html/node_renderers/quote_spec.rb
198
- - spec/gmi2html/node_renderers/sub_heading_spec.rb
199
- - spec/gmi2html/node_renderers/sub_sub_heading_spec.rb
200
- - spec/gmi2html/node_renderers/text_spec.rb
201
- - spec/gmi2html/node_renderers/whitespace_spec.rb
202
- - spec/gmi2html/renderer_spec.rb
203
- - spec/gmi2html_spec.rb
204
- - spec/spec_helper.rb
205
183
  homepage: https://github.com/jebw/gmi2html
206
184
  licenses:
207
185
  - MIT
208
- metadata: {}
186
+ metadata:
187
+ homepage_uri: https://github.com/jebw/gmi2html/
188
+ changelog_uri: https://github.com/jebw/gmi2html/blob/main/CHANGELOG.md
189
+ source_code_uri: https://github.com/jebw/gmi2html/
190
+ documentation_uri: https://github.com/jebw/gmi2html/blob/main/README.md
191
+ bug_tracker_uri: https://github.com/jebw/gmi2html/issues
192
+ rubygems_mfa_required: 'true'
209
193
  post_install_message:
210
194
  rdoc_options: []
211
195
  require_paths:
@@ -221,26 +205,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
205
  - !ruby/object:Gem::Version
222
206
  version: '0'
223
207
  requirements: []
224
- rubygems_version: 3.1.4
208
+ rubygems_version: 3.1.6
225
209
  signing_key:
226
210
  specification_version: 4
227
211
  summary: Gemini to HTML convertor
228
- test_files:
229
- - spec/fixtures/complex.gmi
230
- - spec/fixtures/complex.html
231
- - spec/fixtures/simple.gmi
232
- - spec/fixtures/simple.html
233
- - spec/gmi2html/document_spec.rb
234
- - spec/gmi2html/node_renderers/base_spec.rb
235
- - spec/gmi2html/node_renderers/heading_spec.rb
236
- - spec/gmi2html/node_renderers/link_spec.rb
237
- - spec/gmi2html/node_renderers/list_item_spec.rb
238
- - spec/gmi2html/node_renderers/preformatted_spec.rb
239
- - spec/gmi2html/node_renderers/quote_spec.rb
240
- - spec/gmi2html/node_renderers/sub_heading_spec.rb
241
- - spec/gmi2html/node_renderers/sub_sub_heading_spec.rb
242
- - spec/gmi2html/node_renderers/text_spec.rb
243
- - spec/gmi2html/node_renderers/whitespace_spec.rb
244
- - spec/gmi2html/renderer_spec.rb
245
- - spec/gmi2html_spec.rb
246
- - spec/spec_helper.rb
212
+ test_files: []
data/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*.{css,erb,js,json,rb,ruby,scss,sh,yml}]
4
- indent_size = 2
5
- indent_style = space
6
- charset = utf-8
7
- end_of_line = lf
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .coverage
6
- .yardoc
7
- Gemfile.lock
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- bin
data/.rubocop.yml DELETED
@@ -1,16 +0,0 @@
1
- require:
2
- - rubocop-rake
3
- - rubocop-rspec
4
-
5
- AllCops:
6
- TargetRubyVersion: 2.5
7
- NewCops: enable
8
-
9
- Metrics/BlockLength:
10
- IgnoredMethods: ['describe']
11
-
12
- Style/Documentation:
13
- Enabled: false
14
-
15
- Style/RegexpLiteral:
16
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.7.2
data/.yardoopts DELETED
@@ -1 +0,0 @@
1
- --api public --hide-void-return --markup markdown
@@ -1,19 +0,0 @@
1
- # Hello world
2
-
3
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
4
-
5
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
6
-
7
- ## Some bullets
8
-
9
- * First
10
- * Second
11
- * Third
12
-
13
- ### Third level heading
14
-
15
- This is some more text
16
-
17
- ```
18
- This is a pre-formatted text block
19
- ```
@@ -1,12 +0,0 @@
1
- <h1>Hello world</h1>
2
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
3
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
4
- <h2>Some bullets</h2>
5
- <ul>
6
- <li>First</li>
7
- <li>Second</li>
8
- <li>Third</li>
9
- </ul>
10
- <h3>Third level heading</h3>
11
- <p>This is some more text</p>
12
- <pre>This is a pre-formatted text block</pre>
@@ -1,3 +0,0 @@
1
- # Heading
2
-
3
- This is some sample body content
@@ -1,2 +0,0 @@
1
- <h1>Heading</h1>
2
- <p>This is some sample body content</p>
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::Document do
6
- describe '#new' do
7
- context 'with open file' do
8
- subject { described_class.new StringIO.new("# Title\n\nBody content") }
9
-
10
- it { is_expected.to be_instance_of described_class }
11
- end
12
-
13
- context 'with gemini content' do
14
- subject { described_class.new "# Title\n\nBody content" }
15
-
16
- it { is_expected.to be_instance_of described_class }
17
- end
18
-
19
- context 'without gemini content' do
20
- let(:instance) { described_class.new }
21
-
22
- it { expect { instance }.to raise_exception ArgumentError }
23
- end
24
- end
25
-
26
- describe '#to_html' do
27
- subject { instance.to_html }
28
-
29
- let(:instance) { described_class.new File.read(gemtext_file) }
30
-
31
- shared_examples 'a converted gemtext file' do |filename|
32
- let(:gemtext_file) { "spec/fixtures/#{filename}.gmi" }
33
- let(:expected_html_output) { File.read "spec/fixtures/#{filename}.html" }
34
-
35
- it { is_expected.to eql expected_html_output }
36
- end
37
-
38
- it_behaves_like 'a converted gemtext file', 'simple'
39
- it_behaves_like 'a converted gemtext file', 'complex'
40
- end
41
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Base do
6
- let(:content) { 'Hello, world!' }
7
- let(:instance) { test_node_renderer.new Gemtext::Node.new(content) }
8
-
9
- let :test_node_renderer do
10
- Class.new(described_class) do
11
- def tag
12
- 'test'
13
- end
14
- end
15
- end
16
-
17
- describe '.for_gemtext' do
18
- let(:node) { Gemtext::Text.new content }
19
- let(:instance) { described_class.for_gemtext node }
20
-
21
- it 'will return a Gmi2html::NodeRenderers::Text' do
22
- expect(instance).to be_kind_of Gmi2html::NodeRenderers::Text
23
- end
24
-
25
- it 'will assign the content' do
26
- expect(instance.content).to eq node.content
27
- end
28
- end
29
-
30
- describe '#render' do
31
- it 'will generate a <test> html element' do
32
- expect(instance.render).to match %r{\A<test>[^<]+</test>}
33
- end
34
-
35
- it 'will include the content' do
36
- expect(instance.render).to match %r{>Hello, world!<}
37
- end
38
-
39
- it 'will end with a newline' do
40
- expect(instance.render).to match %r{</test>\n\z}
41
- end
42
-
43
- context 'with html tags in' do
44
- let(:content) { '<p>Hello</p>' }
45
-
46
- it 'will escape the content' do
47
- expect(instance.render).to eql "<test>&lt;p&gt;Hello&lt;/p&gt;</test>\n"
48
- end
49
- end
50
-
51
- context 'with html special chars' do
52
- let(:content) { 'Hello & world' }
53
-
54
- it 'will escape the content' do
55
- expect(instance.render).to eql "<test>Hello &amp; world</test>\n"
56
- end
57
- end
58
- end
59
-
60
- describe '#to_s' do
61
- it 'will generate a <test> html element' do
62
- expect(instance.render).to match %r{\A<test>[^<]+</test>}
63
- end
64
- end
65
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Heading do
6
- let(:instance) { described_class.new Gemtext::Heading.new('Heading') }
7
-
8
- describe '#render' do
9
- subject { instance.render }
10
-
11
- it { is_expected.to eq "<h1>Heading</h1>\n" }
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Link do
6
- let(:instance) { described_class.new link }
7
-
8
- describe '#render' do
9
- subject(:rendered) { instance.render }
10
-
11
- let(:link) { Gemtext::Link.new '/my-capsule my capsule' }
12
-
13
- context 'when only list item' do
14
- it 'will render opening and closing p tags in addition to the a tag' do
15
- expect(rendered).to eql \
16
- %(<p>\n<a href="/my-capsule">my capsule</a>\n</p>\n)
17
- end
18
- end
19
- end
20
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::ListItem do
6
- let(:instance) { described_class.new list_item }
7
-
8
- describe '#render' do
9
- subject(:rendered) { instance.render(prev_node, next_node) }
10
-
11
- let(:other_node) { Gemtext::Node.new('Hello, world!') }
12
- let(:list_item) { Gemtext::ListItem.new 'first item' }
13
-
14
- context 'when only list item' do
15
- let(:prev_node) { other_node }
16
- let(:next_node) { other_node }
17
-
18
- it 'will render opening and closing ul tags in addition to the li tags' do
19
- expect(rendered).to eql "<ul>\n<li>first item</li>\n</ul>\n"
20
- end
21
- end
22
-
23
- context 'when first list item' do
24
- let(:prev_node) { other_node }
25
- let(:next_node) { list_item }
26
-
27
- it 'will render opening ul tag as well as li tags' do
28
- expect(rendered).to eql "<ul>\n<li>first item</li>\n"
29
- end
30
- end
31
-
32
- context 'when last list item' do
33
- let(:prev_node) { list_item }
34
- let(:next_node) { nil }
35
-
36
- it 'will render li tags plus closing ul tag' do
37
- expect(rendered).to eql "<li>first item</li>\n</ul>\n"
38
- end
39
- end
40
-
41
- context 'when in the middle of list items' do
42
- let(:prev_node) { list_item }
43
- let(:next_node) { list_item }
44
-
45
- it 'will render only the li tags' do
46
- expect(rendered).to eql "<li>first item</li>\n"
47
- end
48
- end
49
- end
50
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Preformatted do
6
- let(:instance) { described_class.new preformatted }
7
- let(:preformatted) { Gemtext::Preformatted.new("Some text\n\n\tIndented") }
8
-
9
- describe '#render' do
10
- subject(:rendered) { instance.render }
11
-
12
- it { is_expected.to eq "<pre>Some text\n\n\tIndented</pre>\n" }
13
-
14
- context 'with a specified language' do
15
- let(:preformatted) { Gemtext::Preformatted.new('puts "Hello matz"', 'ruby') }
16
-
17
- it 'includes the language class' do
18
- expect(rendered).to eq \
19
- %(<pre><code class="language-ruby">puts &quot;Hello matz&quot;</code></pre>\n)
20
- end
21
- end
22
- end
23
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Quote do
6
- let(:instance) { described_class.new Gemtext::Quote.new('Quote') }
7
-
8
- describe '#render' do
9
- subject { instance.render }
10
-
11
- it { is_expected.to eq "<blockquote>Quote</blockquote>\n" }
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::SubHeading do
6
- let(:instance) { described_class.new Gemtext::SubHeading.new('Heading 2') }
7
-
8
- describe '#render' do
9
- subject { instance.render }
10
-
11
- it { is_expected.to eq "<h2>Heading 2</h2>\n" }
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::SubSubHeading do
6
- let(:instance) { described_class.new Gemtext::SubSubHeading.new('Heading 3') }
7
-
8
- describe '#render' do
9
- subject { instance.render }
10
-
11
- it { is_expected.to eq "<h3>Heading 3</h3>\n" }
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Text do
6
- let(:instance) { described_class.new Gemtext::Text.new('Hello') }
7
-
8
- describe '#render' do
9
- subject { instance.render }
10
-
11
- it { is_expected.to eq "<p>Hello</p>\n" }
12
- end
13
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::NodeRenderers::Whitespace do
6
- let(:instance) { described_class.new Gemtext::Whitespace.new }
7
-
8
- describe '#render' do
9
- subject { instance.render }
10
-
11
- let(:other_node) { Gemtext::Node.new('Hello, world!') }
12
- let(:whitespace_node) { Gemtext::Whitespace.new }
13
-
14
- it { is_expected.to eq "<br />\n" }
15
-
16
- context 'when first node in document' do
17
- subject { instance.render(nil, other_node) }
18
-
19
- it('will render a break tag') { is_expected.to eq "<br />\n" }
20
- end
21
-
22
- context 'when first node in sequence of whitespace nodes' do
23
- subject { instance.render(other_node, whitespace_node) }
24
-
25
- it('will not render a break tag') { is_expected.to be_nil }
26
- end
27
-
28
- context 'when later node in sequence of whitespace nodes' do
29
- subject { instance.render(whitespace_node, other_node) }
30
-
31
- it('will render a break tag') { is_expected.to eq "<br />\n" }
32
- end
33
- end
34
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html::Renderer do
6
- subject(:renderer) { described_class.new(nodes) }
7
-
8
- let(:node) { Gemtext::Text.new('Hello, world!') }
9
- let(:heading) { Gemtext::Heading.new('Heading') }
10
- let(:heading_renderer) { Gmi2html::NodeRenderers::Heading.new(heading) }
11
- let(:nodes) { [heading, node, node] }
12
-
13
- describe '#to_html' do
14
- subject(:rendered) { renderer.to_html }
15
-
16
- before do
17
- allow(Gmi2html::NodeRenderers::Base).to \
18
- receive(:for_gemtext).and_call_original
19
-
20
- allow(Gmi2html::NodeRenderers::Base).to \
21
- receive(:for_gemtext).with(heading).and_return(heading_renderer)
22
- end
23
-
24
- it 'will combine the nodes' do
25
- expect(rendered).to eql \
26
- "<h1>Heading</h1>\n<p>Hello, world!</p>\n<p>Hello, world!</p>\n"
27
- end
28
-
29
- context 'with nodes which render a nil response' do
30
- before { allow(heading_renderer).to receive(:render).and_return(nil) }
31
-
32
- it 'will skip those nodes' do
33
- expect(rendered).to eql("<p>Hello, world!</p>\n<p>Hello, world!</p>\n")
34
- end
35
- end
36
-
37
- context 'with multiple nodes' do
38
- let(:nodes) { [node, heading, node] }
39
-
40
- before { allow(heading_renderer).to receive(:render).and_call_original }
41
-
42
- it 'will pass surrounding nodes for context into NodeRenderer#render' do
43
- renderer.to_html
44
- expect(heading_renderer).to have_received(:render).with(node, node)
45
- end
46
- end
47
- end
48
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Gmi2html do
6
- describe 'VERSION' do
7
- subject { described_class::VERSION }
8
-
9
- it { is_expected.to eql '0.1.0' }
10
- end
11
- end
data/spec/spec_helper.rb DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'byebug'
4
- require 'simplecov'
5
- SimpleCov.start do
6
- add_filter '/spec/'
7
- end
8
-
9
- require 'gmi2html'
10
-
11
- RSpec.configure do |config|
12
- config.filter_run_when_matching :focus
13
-
14
- config.disable_monkey_patching!
15
-
16
- if config.files_to_run.one?
17
- # Use the documentation formatter for detailed output,
18
- # unless a formatter has already been configured
19
- # (e.g. via a command-line flag).
20
- config.default_formatter = 'doc'
21
- end
22
-
23
- config.order = :random
24
-
25
- Kernel.srand config.seed
26
-
27
- config.raise_errors_for_deprecations!
28
- end