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 +4 -4
- data/CHANGELOG.md +6 -0
- data/{README.gmi → README.md} +7 -5
- data/gmi2html.gemspec +12 -1
- data/lib/gmi2html/node_renderers/link.rb +3 -3
- data/lib/gmi2html/version.rb +1 -1
- metadata +13 -47
- data/.editorconfig +0 -9
- data/.gitignore +0 -18
- data/.rubocop.yml +0 -16
- data/.ruby-version +0 -1
- data/.yardoopts +0 -1
- data/spec/fixtures/complex.gmi +0 -19
- data/spec/fixtures/complex.html +0 -12
- data/spec/fixtures/simple.gmi +0 -3
- data/spec/fixtures/simple.html +0 -2
- data/spec/gmi2html/document_spec.rb +0 -41
- data/spec/gmi2html/node_renderers/base_spec.rb +0 -65
- data/spec/gmi2html/node_renderers/heading_spec.rb +0 -13
- data/spec/gmi2html/node_renderers/link_spec.rb +0 -20
- data/spec/gmi2html/node_renderers/list_item_spec.rb +0 -50
- data/spec/gmi2html/node_renderers/preformatted_spec.rb +0 -23
- data/spec/gmi2html/node_renderers/quote_spec.rb +0 -13
- data/spec/gmi2html/node_renderers/sub_heading_spec.rb +0 -13
- data/spec/gmi2html/node_renderers/sub_sub_heading_spec.rb +0 -13
- data/spec/gmi2html/node_renderers/text_spec.rb +0 -13
- data/spec/gmi2html/node_renderers/whitespace_spec.rb +0 -34
- data/spec/gmi2html/renderer_spec.rb +0 -48
- data/spec/gmi2html_spec.rb +0 -11
- data/spec/spec_helper.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f21a04e45e6fddd82e7f5b4000b504cb4b9b241514bde8f27ae3d40bda33d42
|
4
|
+
data.tar.gz: 0331d6c2cae8da1b1e670463a18c8ae67ac7a41a5ec5204dd95e8a578147e058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a8fd2936bfa0581246f08d89669ff8a9461692263ba2b3e71f0dc47d94f7de2a5ec4ac5362dafaf95589d87facf464f728ebf8b6354e9cfcaeae781b791e1d3
|
7
|
+
data.tar.gz: de900159e29c7cc27d2f0ce593f8a54ba1b5845aa0b02eaa53aead0ed1b37b9c771ca04529413549ec81cf8b2adb61cfea0791d9b2521ddcd362b41161cf70cb
|
data/CHANGELOG.md
ADDED
data/{README.gmi → README.md}
RENAMED
@@ -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
|
-
|
12
|
-
|
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
|
-
|
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(
|
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
|
data/lib/gmi2html/version.rb
CHANGED
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.
|
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:
|
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
|
-
-
|
163
|
-
- ".gitignore"
|
164
|
-
- ".rubocop.yml"
|
165
|
-
- ".ruby-version"
|
166
|
-
- ".yardoopts"
|
162
|
+
- CHANGELOG.md
|
167
163
|
- Gemfile
|
168
164
|
- LICENSE.txt
|
169
|
-
- README.
|
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.
|
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
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
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
|
data/spec/fixtures/complex.gmi
DELETED
@@ -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
|
-
```
|
data/spec/fixtures/complex.html
DELETED
@@ -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>
|
data/spec/fixtures/simple.gmi
DELETED
data/spec/fixtures/simple.html
DELETED
@@ -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><p>Hello</p></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 & 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 "Hello matz"</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
|
data/spec/gmi2html_spec.rb
DELETED
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
|