koara-html 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +4 -0
- data/README.md +3 -4
- data/Rakefile +1 -1
- data/koara-html.gemspec +2 -1
- data/lib/koara/html.rb +1 -1
- data/lib/koara/html/html5renderer.rb +14 -2
- data/test/html5renderer_test.rb +25 -3
- metadata +17 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 739e30bab2a27055ab39b935c21f8612acb27958
|
4
|
+
data.tar.gz: f76f2319a2f399d76bf4995113b8f44ffbca7245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 409e1cf06d5ff6af81c46f4ded7594f7b96be04af506d4c6817f0ca4b1c54ec0e72dbcfdb1776ba8e72d85ea384b5214ce3e65d41cc8444102b9e331455c6c7c
|
7
|
+
data.tar.gz: 8b62c6a170fc9427ca8203dbcd7b35ba63eea6cfc727d0bcad6f370bdb2b999a60d5c211b071ad670f9adc06ea6f854824e8dbaa1607adb90a2bdd61a51e6894
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/koara-html.gemspec
CHANGED
@@ -20,5 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.test_files = s.files.grep(%r{^(test|features)/})
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_development_dependency 'rake', '~>
|
23
|
+
s.add_development_dependency 'rake', '~> 1.4'
|
24
|
+
s.add_development_dependency 'bundler', '~> 1.2'
|
24
25
|
end
|
data/lib/koara/html.rb
CHANGED
@@ -3,21 +3,33 @@ module Koara
|
|
3
3
|
module Html
|
4
4
|
class Html5Renderer
|
5
5
|
attr_accessor :partial
|
6
|
+
attr_accessor :hard_wrap
|
7
|
+
attr_accessor :heading_ids
|
6
8
|
|
7
9
|
def initialize
|
8
10
|
@partial = true
|
11
|
+
@hard_wrap = false
|
12
|
+
@heading_ids = false
|
9
13
|
end
|
10
14
|
|
11
15
|
def visit_document(node)
|
12
16
|
@level = 0
|
13
17
|
@list_sequence = Array.new
|
14
18
|
@out = StringIO.new
|
15
|
-
@hard_wrap = false
|
16
19
|
node.children_accept(self)
|
17
20
|
end
|
18
21
|
|
19
22
|
def visit_heading(node)
|
20
|
-
@out << indent + '<h' + node.value.to_s
|
23
|
+
@out << indent + '<h' + node.value.to_s
|
24
|
+
if @heading_ids
|
25
|
+
id = ''
|
26
|
+
node.children.each do |n|
|
27
|
+
id << n.value.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
@out << " id=\"" + id.downcase.gsub(/ /, '_') + "\""
|
31
|
+
end
|
32
|
+
@out << '>'
|
21
33
|
node.children_accept(self)
|
22
34
|
@out << '</h' + node.value.to_s + ">\n"
|
23
35
|
unless node.nested
|
data/test/html5renderer_test.rb
CHANGED
@@ -5,16 +5,23 @@ require 'minitest/autorun'
|
|
5
5
|
class Html5RendererTest < MiniTest::Unit::TestCase
|
6
6
|
|
7
7
|
def setup
|
8
|
-
parser = Koara::Parser.new
|
9
|
-
@document = parser.parse('Test')
|
8
|
+
@parser = Koara::Parser.new
|
10
9
|
@renderer = Koara::Html::Html5Renderer.new()
|
11
10
|
end
|
12
11
|
|
13
|
-
def
|
12
|
+
def test_render
|
13
|
+
@document = @parser.parse('Test')
|
14
14
|
@document.accept(@renderer)
|
15
15
|
assert_equal("<p>Test</p>", @renderer.output)
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_render_hardwrap_true
|
19
|
+
@renderer.hard_wrap = true;
|
20
|
+
@document = @parser.parse("a\nb")
|
21
|
+
@document.accept(@renderer)
|
22
|
+
assert_equal("<p>a<br>\nb</p>", @renderer.output)
|
23
|
+
end
|
24
|
+
|
18
25
|
def test_no_partial_result
|
19
26
|
expected = "<!DOCTYPE html>\n"
|
20
27
|
expected << "<html>\n";
|
@@ -24,8 +31,23 @@ class Html5RendererTest < MiniTest::Unit::TestCase
|
|
24
31
|
expected << "</html>\n";
|
25
32
|
|
26
33
|
@renderer.partial = false;
|
34
|
+
@document = @parser.parse('Test')
|
27
35
|
@document.accept(@renderer)
|
28
36
|
assert_equal(expected, @renderer.output)
|
29
37
|
end
|
30
38
|
|
39
|
+
def test_heading_ids_true
|
40
|
+
@renderer.heading_ids = true;
|
41
|
+
@document = @parser.parse('= A')
|
42
|
+
@document.accept(@renderer)
|
43
|
+
assert_equal("<h1 id=\"a\">A</h1>", @renderer.output)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_heading_ids_true_multiple_words
|
47
|
+
@renderer.heading_ids = true;
|
48
|
+
@document = @parser.parse('= This is a test')
|
49
|
+
@document.accept(@renderer)
|
50
|
+
assert_equal("<h1 id=\"this_is_a_test\">This is a test</h1>", @renderer.output)
|
51
|
+
end
|
52
|
+
|
31
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koara-html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Van Den Heuvel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,20 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - '>='
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 10.4.2
|
19
|
+
version: '1.4'
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
31
39
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
40
|
+
version: '1.2'
|
33
41
|
description: Koara to HTML parser written in Ruby
|
34
42
|
email:
|
35
43
|
- andy.vandenheuvel@gmail.com
|