commonmarker 0.19.0 → 0.21.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/README.md +2 -3
- data/Rakefile +16 -4
- data/bin/commonmarker +82 -44
- data/commonmarker.gemspec +9 -12
- data/ext/commonmarker/blocks.c +89 -29
- data/ext/commonmarker/buffer.c +0 -1
- data/ext/commonmarker/chunk.h +0 -1
- data/ext/commonmarker/cmark-gfm-core-extensions.h +24 -1
- data/ext/commonmarker/cmark-gfm.h +14 -8
- data/ext/commonmarker/cmark-gfm_version.h +2 -2
- data/ext/commonmarker/commonmark.c +9 -4
- data/ext/commonmarker/commonmarker.c +120 -78
- data/ext/commonmarker/html.c +4 -4
- data/ext/commonmarker/inlines.c +21 -14
- data/ext/commonmarker/iterator.h +0 -1
- data/ext/commonmarker/map.h +0 -1
- data/ext/commonmarker/node.h +2 -0
- data/ext/commonmarker/parser.h +2 -1
- data/ext/commonmarker/render.c +16 -14
- data/ext/commonmarker/render.h +0 -1
- data/ext/commonmarker/scanners.c +777 -951
- data/ext/commonmarker/scanners.h +0 -2
- data/ext/commonmarker/table.c +52 -13
- data/ext/commonmarker/tasklist.c +34 -13
- data/lib/commonmarker.rb +5 -4
- data/lib/commonmarker/config.rb +5 -4
- data/lib/commonmarker/node.rb +1 -1
- data/lib/commonmarker/node/inspect.rb +12 -12
- data/lib/commonmarker/renderer.rb +7 -7
- data/lib/commonmarker/renderer/html_renderer.rb +22 -35
- data/lib/commonmarker/version.rb +1 -1
- data/test/benchmark.rb +1 -5
- data/test/fixtures/strong.md +1 -0
- data/test/fixtures/table.md +10 -0
- data/test/test_attributes.rb +3 -3
- data/test/test_commands.rb +31 -0
- data/test/test_commonmark.rb +11 -11
- data/test/test_encoding.rb +1 -2
- data/test/test_extensions.rb +40 -52
- data/test/test_footnotes.rb +9 -9
- data/test/test_gc.rb +2 -0
- data/test/test_helper.rb +15 -8
- data/test/test_maliciousness.rb +192 -190
- data/test/test_node.rb +10 -12
- data/test/test_options.rb +15 -15
- data/test/test_pathological_inputs.rb +2 -2
- data/test/test_plaintext.rb +21 -21
- data/test/test_renderer.rb +9 -9
- data/test/test_spec.rb +3 -2
- data/test/test_tasklists.rb +22 -6
- metadata +51 -46
data/lib/commonmarker/version.rb
CHANGED
data/test/benchmark.rb
CHANGED
@@ -13,16 +13,12 @@ end
|
|
13
13
|
|
14
14
|
benchinput = File.open('test/benchinput.md', 'r').read
|
15
15
|
|
16
|
-
printf("input size =
|
16
|
+
printf("input size = %<bytes>d bytes\n\n", benchinput.bytesize)
|
17
17
|
|
18
18
|
dobench('redcarpet') do
|
19
19
|
Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: false, tables: false).render(benchinput)
|
20
20
|
end
|
21
21
|
|
22
|
-
dobench('github-markdown') do
|
23
|
-
GitHub::Markdown.render(benchinput)
|
24
|
-
end
|
25
|
-
|
26
22
|
dobench('commonmarker with to_html') do
|
27
23
|
CommonMarker.render_html(benchinput)
|
28
24
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
I am **strong**
|
data/test/test_attributes.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class TestAttributes < Minitest::Test
|
6
6
|
def setup
|
7
|
-
contents =
|
7
|
+
contents = fixtures_file('dingus.md')
|
8
8
|
@doc = CommonMarker.render_doc(contents.strip)
|
9
9
|
end
|
10
10
|
|
@@ -15,9 +15,9 @@ class TestAttributes < Minitest::Test
|
|
15
15
|
sourcepos << node.sourcepos
|
16
16
|
end
|
17
17
|
|
18
|
-
sourcepos.delete_if { |h| h.values.all?
|
18
|
+
sourcepos.delete_if { |h| h.values.all?(&:zero?) }
|
19
19
|
|
20
|
-
result = [{start_line: 1, start_column: 1, end_line: 10, end_column: 12}, {start_line: 1, start_column: 1, end_line: 1, end_column: 17}, {start_line: 1, start_column: 4, end_line: 1, end_column: 17}, {start_line: 3, start_column: 1, end_line: 5, end_column: 36}, {start_line: 3, start_column: 1, end_line: 3, end_column: 55}, {start_line: 4, start_column: 1, end_line: 4, end_column: 53}, {start_line: 4, start_column: 2, end_line: 4, end_column: 14}, {start_line: 4, start_column: 54, end_line: 4, end_column: 58}, {start_line: 5, start_column: 1, end_line: 5, end_column: 36}, {start_line: 7, start_column: 1, end_line: 10, end_column: 12}, {start_line: 7, start_column: 1, end_line: 7, end_column: 11}, {start_line: 7, start_column: 4, end_line: 7, end_column: 11}, {start_line: 7, start_column: 4, end_line: 7, end_column: 11}, {start_line: 8, start_column: 1, end_line: 10, end_column: 12}, {start_line: 8, start_column: 4, end_line: 8, end_column: 11}, {start_line: 8, start_column: 4, end_line: 8, end_column: 11}, {start_line: 9, start_column: 4, end_line: 10, end_column: 12}, {start_line: 9, start_column: 4, end_line: 9, end_column: 12}, {start_line: 9, start_column: 6, end_line: 9, end_column: 12}, {start_line: 9, start_column: 6, end_line: 9, end_column: 12}, {start_line: 10, start_column: 4, end_line: 10, end_column: 12}, {start_line: 10, start_column: 6, end_line: 10, end_column: 12}, {start_line: 10, start_column: 6, end_line: 10, end_column: 12}]
|
20
|
+
result = [{ start_line: 1, start_column: 1, end_line: 10, end_column: 12 }, { start_line: 1, start_column: 1, end_line: 1, end_column: 17 }, { start_line: 1, start_column: 4, end_line: 1, end_column: 17 }, { start_line: 3, start_column: 1, end_line: 5, end_column: 36 }, { start_line: 3, start_column: 1, end_line: 3, end_column: 55 }, { start_line: 4, start_column: 1, end_line: 4, end_column: 53 }, { start_line: 4, start_column: 2, end_line: 4, end_column: 14 }, { start_line: 4, start_column: 54, end_line: 4, end_column: 58 }, { start_line: 5, start_column: 1, end_line: 5, end_column: 36 }, { start_line: 7, start_column: 1, end_line: 10, end_column: 12 }, { start_line: 7, start_column: 1, end_line: 7, end_column: 11 }, { start_line: 7, start_column: 4, end_line: 7, end_column: 11 }, { start_line: 7, start_column: 4, end_line: 7, end_column: 11 }, { start_line: 8, start_column: 1, end_line: 10, end_column: 12 }, { start_line: 8, start_column: 4, end_line: 8, end_column: 11 }, { start_line: 8, start_column: 4, end_line: 8, end_column: 11 }, { start_line: 9, start_column: 4, end_line: 10, end_column: 12 }, { start_line: 9, start_column: 4, end_line: 9, end_column: 12 }, { start_line: 9, start_column: 6, end_line: 9, end_column: 12 }, { start_line: 9, start_column: 6, end_line: 9, end_column: 12 }, { start_line: 10, start_column: 4, end_line: 10, end_column: 12 }, { start_line: 10, start_column: 6, end_line: 10, end_column: 12 }, { start_line: 10, start_column: 6, end_line: 10, end_column: 12 }]
|
21
21
|
|
22
22
|
assert_equal result, sourcepos
|
23
23
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class TestCommands < Minitest::Test
|
6
|
+
def test_basic
|
7
|
+
out = make_bin('strong.md')
|
8
|
+
assert_equal out, '<p>I am <strong>strong</strong></p>'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_does_not_have_extensions
|
12
|
+
out = make_bin('table.md')
|
13
|
+
assert out.include?('| a')
|
14
|
+
refute out.include?('<p><del>hi</del>')
|
15
|
+
refute out.include?('<table> <tr> <th> a </th> <td> c </td>')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_understands_extensions
|
19
|
+
out = make_bin('table.md', '--extension=table')
|
20
|
+
refute out.include?('| a')
|
21
|
+
refute out.include?('<p><del>hi</del>')
|
22
|
+
%w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert out.include?(html) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_understands_multiple_extensions
|
26
|
+
out = make_bin('table.md', '--extension=table,strikethrough')
|
27
|
+
refute out.include?('| a')
|
28
|
+
assert out.include?('<p><del>hi</del>')
|
29
|
+
%w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert out.include?(html) }
|
30
|
+
end
|
31
|
+
end
|
data/test/test_commonmark.rb
CHANGED
@@ -3,22 +3,22 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class TestCommonmark < Minitest::Test
|
6
|
-
HTML_COMMENT =
|
6
|
+
HTML_COMMENT = /<!--.*?-->\s?/.freeze
|
7
7
|
|
8
8
|
def setup
|
9
|
-
@markdown =
|
10
|
-
Hi *there*!
|
9
|
+
@markdown = <<~MD
|
10
|
+
Hi *there*!
|
11
11
|
|
12
|
-
1. I am a numeric list.
|
13
|
-
2. I continue the list.
|
14
|
-
* Suddenly, an unordered list!
|
15
|
-
* What fun!
|
12
|
+
1. I am a numeric list.
|
13
|
+
2. I continue the list.
|
14
|
+
* Suddenly, an unordered list!
|
15
|
+
* What fun!
|
16
16
|
|
17
|
-
Okay, _enough_.
|
17
|
+
Okay, _enough_.
|
18
18
|
|
19
|
-
| a | b |
|
20
|
-
| --- | --- |
|
21
|
-
| c | d |
|
19
|
+
| a | b |
|
20
|
+
| --- | --- |
|
21
|
+
| c | d |
|
22
22
|
MD
|
23
23
|
end
|
24
24
|
|
data/test/test_encoding.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -6,7 +5,7 @@ require 'test_helper'
|
|
6
5
|
class TestEncoding < Minitest::Test
|
7
6
|
# see http://git.io/vq4FR
|
8
7
|
def test_encoding
|
9
|
-
contents =
|
8
|
+
contents = fixtures_file('curly.md')
|
10
9
|
doc = CommonMarker.render_doc(contents, :SMART)
|
11
10
|
render = doc.to_html
|
12
11
|
assert_equal render.rstrip, '<p>This curly quote “makes commonmarker throw an exception”.</p>'
|
data/test/test_extensions.rb
CHANGED
@@ -4,18 +4,7 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class TestExtensions < Minitest::Test
|
6
6
|
def setup
|
7
|
-
@markdown =
|
8
|
-
One extension:
|
9
|
-
|
10
|
-
| a | b |
|
11
|
-
| --- | --- |
|
12
|
-
| c | d |
|
13
|
-
| **x** | |
|
14
|
-
|
15
|
-
Another extension:
|
16
|
-
|
17
|
-
~~hi~~
|
18
|
-
MD
|
7
|
+
@markdown = fixtures_file('table.md')
|
19
8
|
end
|
20
9
|
|
21
10
|
def test_uses_specified_extensions
|
@@ -27,7 +16,7 @@ Another extension:
|
|
27
16
|
|
28
17
|
CommonMarker.render_html(@markdown, :DEFAULT, %i[table]).tap do |out|
|
29
18
|
refute out.include?('| a')
|
30
|
-
%w
|
19
|
+
%w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert out.include?(html) }
|
31
20
|
assert out.include?('~~hi~~')
|
32
21
|
end
|
33
22
|
|
@@ -45,7 +34,6 @@ Another extension:
|
|
45
34
|
refute out.include?('| <strong>x</strong>')
|
46
35
|
refute out.include?('~~hi~~')
|
47
36
|
end
|
48
|
-
|
49
37
|
end
|
50
38
|
|
51
39
|
def test_extensions_with_renderers
|
@@ -53,13 +41,13 @@ Another extension:
|
|
53
41
|
|
54
42
|
doc.to_html.tap do |out|
|
55
43
|
refute out.include?('| a')
|
56
|
-
%w
|
44
|
+
%w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert out.include?(html) }
|
57
45
|
assert out.include?('~~hi~~')
|
58
46
|
end
|
59
47
|
|
60
48
|
HtmlRenderer.new.render(doc).tap do |out|
|
61
49
|
refute out.include?('| a')
|
62
|
-
%w
|
50
|
+
%w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert out.include?(html) }
|
63
51
|
assert out.include?('~~hi~~')
|
64
52
|
end
|
65
53
|
|
@@ -75,51 +63,51 @@ Another extension:
|
|
75
63
|
|
76
64
|
def test_comments_are_kept_as_expected
|
77
65
|
assert_equal "<!--hello--> <blah> <xmp>\n",
|
78
|
-
|
66
|
+
CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :UNSAFE, %i[tagfilter])
|
79
67
|
end
|
80
68
|
|
81
69
|
def test_table_prefer_style_attributes
|
82
|
-
|
83
|
-
<table>
|
84
|
-
<thead>
|
85
|
-
<tr>
|
86
|
-
<th style="text-align: left">aaa</th>
|
87
|
-
<th>bbb</th>
|
88
|
-
<th style="text-align: center">ccc</th>
|
89
|
-
<th>ddd</th>
|
90
|
-
<th style="text-align: right">eee</th>
|
91
|
-
</tr>
|
92
|
-
</thead>
|
93
|
-
<tbody>
|
94
|
-
<tr>
|
95
|
-
<td style="text-align: left">fff</td>
|
96
|
-
<td>ggg</td>
|
97
|
-
<td style="text-align: center">hhh</td>
|
98
|
-
<td>iii</td>
|
99
|
-
<td style="text-align: right">jjj</td>
|
100
|
-
</tr>
|
101
|
-
</tbody>
|
102
|
-
</table>
|
103
|
-
|
104
|
-
aaa | bbb | ccc | ddd | eee
|
105
|
-
:-- | --- | :-: | --- | --:
|
106
|
-
fff | ggg | hhh | iii | jjj
|
107
|
-
|
70
|
+
assert_equal(<<~HTML, CommonMarker.render_html(<<~MD, :TABLE_PREFER_STYLE_ATTRIBUTES, %i[table]))
|
71
|
+
<table>
|
72
|
+
<thead>
|
73
|
+
<tr>
|
74
|
+
<th style="text-align: left">aaa</th>
|
75
|
+
<th>bbb</th>
|
76
|
+
<th style="text-align: center">ccc</th>
|
77
|
+
<th>ddd</th>
|
78
|
+
<th style="text-align: right">eee</th>
|
79
|
+
</tr>
|
80
|
+
</thead>
|
81
|
+
<tbody>
|
82
|
+
<tr>
|
83
|
+
<td style="text-align: left">fff</td>
|
84
|
+
<td>ggg</td>
|
85
|
+
<td style="text-align: center">hhh</td>
|
86
|
+
<td>iii</td>
|
87
|
+
<td style="text-align: right">jjj</td>
|
88
|
+
</tr>
|
89
|
+
</tbody>
|
90
|
+
</table>
|
91
|
+
HTML
|
92
|
+
aaa | bbb | ccc | ddd | eee
|
93
|
+
:-- | --- | :-: | --- | --:
|
94
|
+
fff | ggg | hhh | iii | jjj
|
95
|
+
MD
|
108
96
|
end
|
109
97
|
|
110
98
|
def test_plaintext
|
111
|
-
assert_equal(
|
112
|
-
Hello ~there~.
|
99
|
+
assert_equal(<<~HTML, CommonMarker.render_doc(<<~MD, :DEFAULT, %i[table strikethrough]).to_plaintext)
|
100
|
+
Hello ~there~.
|
113
101
|
|
114
|
-
| a |
|
115
|
-
| --- |
|
116
|
-
| b |
|
102
|
+
| a |
|
103
|
+
| --- |
|
104
|
+
| b |
|
117
105
|
HTML
|
118
|
-
Hello ~~there~~.
|
106
|
+
Hello ~~there~~.
|
119
107
|
|
120
|
-
| a |
|
121
|
-
| - |
|
122
|
-
| b |
|
108
|
+
| a |
|
109
|
+
| - |
|
110
|
+
| b |
|
123
111
|
MD
|
124
112
|
end
|
125
113
|
end
|
data/test/test_footnotes.rb
CHANGED
@@ -5,15 +5,15 @@ require 'test_helper'
|
|
5
5
|
class TestFootnotes < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@doc = CommonMarker.render_doc("Hello[^hi].\n\n[^hi]: Hey!\n", :FOOTNOTES)
|
8
|
-
@expected =
|
9
|
-
<p>Hello<sup class="footnote-ref"><a href="#fn1" id="fnref1">1</a></sup>.</p>
|
10
|
-
<section class="footnotes">
|
11
|
-
<ol>
|
12
|
-
<li id="fn1">
|
13
|
-
<p>Hey! <a href="#fnref1" class="footnote-backref">↩</a></p>
|
14
|
-
</li>
|
15
|
-
</ol>
|
16
|
-
</section>
|
8
|
+
@expected = <<~HTML
|
9
|
+
<p>Hello<sup class="footnote-ref"><a href="#fn1" id="fnref1">1</a></sup>.</p>
|
10
|
+
<section class="footnotes">
|
11
|
+
<ol>
|
12
|
+
<li id="fn1">
|
13
|
+
<p>Hey! <a href="#fnref1" class="footnote-backref">↩</a></p>
|
14
|
+
</li>
|
15
|
+
</ol>
|
16
|
+
</section>
|
17
17
|
HTML
|
18
18
|
end
|
19
19
|
|
data/test/test_gc.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'commonmarker'
|
@@ -6,10 +5,18 @@ require 'minitest/autorun'
|
|
6
5
|
require 'minitest/pride'
|
7
6
|
require 'minitest/focus'
|
8
7
|
|
9
|
-
include CommonMarker
|
8
|
+
include CommonMarker # rubocop:disable Style/MixinUsage
|
10
9
|
|
11
10
|
FIXTURES_DIR = File.join(File.dirname(__FILE__), 'fixtures')
|
12
11
|
|
12
|
+
def fixtures_file(file)
|
13
|
+
File.read(File.join(FIXTURES_DIR, file), encoding: 'utf-8')
|
14
|
+
end
|
15
|
+
|
16
|
+
def make_bin(file, args = '')
|
17
|
+
`ruby bin/commonmarker #{File.join(FIXTURES_DIR, file)} #{args}`.chomp
|
18
|
+
end
|
19
|
+
|
13
20
|
def open_spec_file(filename)
|
14
21
|
line_number = 0
|
15
22
|
start_line = 0
|
@@ -31,7 +38,7 @@ def open_spec_file(filename)
|
|
31
38
|
l = line.strip
|
32
39
|
if l =~ /^`{32} example(.*)$/
|
33
40
|
state = 1
|
34
|
-
extensions =
|
41
|
+
extensions = Regexp.last_match(1).split
|
35
42
|
elsif l == '`' * 32
|
36
43
|
state = 0
|
37
44
|
example_number += 1
|
@@ -43,7 +50,7 @@ def open_spec_file(filename)
|
|
43
50
|
start_line: start_line,
|
44
51
|
end_line: end_line,
|
45
52
|
section: headertext,
|
46
|
-
extensions: extensions.map(&:to_sym)
|
53
|
+
extensions: extensions.map(&:to_sym)
|
47
54
|
}
|
48
55
|
start_line = 0
|
49
56
|
markdown_lines = []
|
@@ -51,11 +58,11 @@ def open_spec_file(filename)
|
|
51
58
|
elsif l == '.'
|
52
59
|
state = 2
|
53
60
|
elsif state == 1
|
54
|
-
start_line = line_number - 1 if start_line
|
55
|
-
markdown_lines <<
|
61
|
+
start_line = line_number - 1 if start_line.zero?
|
62
|
+
markdown_lines << line.to_s
|
56
63
|
elsif state == 2
|
57
|
-
html_lines <<
|
58
|
-
elsif state
|
64
|
+
html_lines << line.to_s
|
65
|
+
elsif state.zero? && header_re.match(line)
|
59
66
|
headertext = line.sub(header_re, '').strip
|
60
67
|
end
|
61
68
|
end
|
data/test/test_maliciousness.rb
CHANGED
@@ -2,264 +2,266 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def test_init_with_bad_type
|
11
|
-
assert_raises TypeError do
|
12
|
-
Node.new(123)
|
5
|
+
module CommonMarker
|
6
|
+
class TestMaliciousness < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@doc = CommonMarker.render_doc('Hi *there*')
|
13
9
|
end
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
def test_init_with_bad_type
|
12
|
+
assert_raises TypeError do
|
13
|
+
Node.new(123)
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
assert_raises NodeError do
|
17
|
+
Node.new(:totes_fake)
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
assert_raises TypeError do
|
21
|
+
Node.new([])
|
22
|
+
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
24
|
+
assert_raises TypeError do
|
25
|
+
Node.new([23])
|
26
|
+
end
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
assert_raises TypeError do
|
29
|
+
Node.new(nil)
|
30
|
+
end
|
35
31
|
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
def test_rendering_with_bad_type
|
34
|
+
assert_raises TypeError do
|
35
|
+
CommonMarker.render_html("foo \n baz", 123)
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
assert_raises TypeError do
|
39
|
+
CommonMarker.render_html("foo \n baz", :totes_fake)
|
40
|
+
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
assert_raises TypeError do
|
43
|
+
CommonMarker.render_html("foo \n baz", [])
|
44
|
+
end
|
48
45
|
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
assert_raises TypeError do
|
47
|
+
CommonMarker.render_html("foo \n baz", [23])
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
assert_raises TypeError do
|
51
|
+
CommonMarker.render_html("foo \n baz", nil)
|
52
|
+
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
assert_raises TypeError do
|
55
|
+
CommonMarker.render_html("foo \n baz", [:SMART, 'totes_fake'])
|
56
|
+
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
assert_raises TypeError do
|
59
|
+
CommonMarker.render_html(123)
|
60
|
+
end
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
assert_raises TypeError do
|
63
|
+
CommonMarker.render_html([123])
|
64
|
+
end
|
68
65
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
assert_equal err.message, 'option \':SMART\' does not exist for CommonMarker::Config::Render'
|
66
|
+
assert_raises TypeError do
|
67
|
+
CommonMarker.render_html(nil)
|
68
|
+
end
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
err = assert_raises TypeError do
|
71
|
+
CommonMarker.render_html("foo \n baz", [:SMART])
|
72
|
+
end
|
73
|
+
assert_equal err.message, 'option \':SMART\' does not exist for CommonMarker::Config::Render'
|
77
74
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
assert_equal err.message, 'option \':safe\' does not exist for CommonMarker::Config::Parse'
|
75
|
+
assert_raises TypeError do
|
76
|
+
CommonMarker.render_doc("foo \n baz", 123)
|
77
|
+
end
|
82
78
|
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
err = assert_raises TypeError do
|
80
|
+
CommonMarker.render_doc("foo \n baz", :safe)
|
81
|
+
end
|
82
|
+
assert_equal err.message, 'option \':safe\' does not exist for CommonMarker::Config::Parse'
|
86
83
|
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
assert_raises TypeError do
|
85
|
+
CommonMarker.render_doc("foo \n baz", :totes_fake)
|
86
|
+
end
|
90
87
|
|
91
|
-
|
92
|
-
|
93
|
-
|
88
|
+
assert_raises TypeError do
|
89
|
+
CommonMarker.render_doc("foo \n baz", [])
|
90
|
+
end
|
94
91
|
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
assert_raises TypeError do
|
93
|
+
CommonMarker.render_doc("foo \n baz", [23])
|
94
|
+
end
|
98
95
|
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
assert_raises TypeError do
|
97
|
+
CommonMarker.render_doc("foo \n baz", nil)
|
98
|
+
end
|
102
99
|
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
assert_raises TypeError do
|
101
|
+
CommonMarker.render_doc("foo \n baz", [:SMART, 'totes_fake'])
|
102
|
+
end
|
106
103
|
|
107
|
-
|
108
|
-
|
109
|
-
|
104
|
+
assert_raises TypeError do
|
105
|
+
CommonMarker.render_doc(123)
|
106
|
+
end
|
110
107
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
108
|
+
assert_raises TypeError do
|
109
|
+
CommonMarker.render_doc([123])
|
110
|
+
end
|
115
111
|
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
assert_raises TypeError do
|
113
|
+
CommonMarker.render_doc(nil)
|
114
|
+
end
|
119
115
|
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_bad_walking
|
123
|
-
assert_nil @doc.parent
|
124
|
-
assert_nil @doc.previous
|
125
|
-
end
|
126
116
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
117
|
+
def test_bad_set_string_content
|
118
|
+
assert_raises TypeError do
|
119
|
+
@doc.string_content = 123
|
120
|
+
end
|
131
121
|
end
|
132
122
|
|
133
|
-
|
134
|
-
|
135
|
-
@doc.
|
123
|
+
def test_bad_walking
|
124
|
+
assert_nil @doc.parent
|
125
|
+
assert_nil @doc.previous
|
136
126
|
end
|
137
127
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
128
|
+
def test_bad_insertion
|
129
|
+
code = Node.new(:code)
|
130
|
+
assert_raises NodeError do
|
131
|
+
@doc.insert_before(code)
|
132
|
+
end
|
142
133
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
134
|
+
paragraph = Node.new(:paragraph)
|
135
|
+
assert_raises NodeError do
|
136
|
+
@doc.insert_after(paragraph)
|
137
|
+
end
|
147
138
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
139
|
+
document = Node.new(:document)
|
140
|
+
assert_raises NodeError do
|
141
|
+
@doc.prepend_child(document)
|
142
|
+
end
|
153
143
|
|
154
|
-
|
155
|
-
|
156
|
-
|
144
|
+
assert_raises NodeError do
|
145
|
+
@doc.append_child(document)
|
146
|
+
end
|
157
147
|
end
|
158
148
|
|
159
|
-
|
160
|
-
|
161
|
-
|
149
|
+
def test_bad_url_get
|
150
|
+
assert_raises NodeError do
|
151
|
+
@doc.url
|
152
|
+
end
|
162
153
|
end
|
163
|
-
end
|
164
154
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
end
|
155
|
+
def test_bad_url_set
|
156
|
+
assert_raises NodeError do
|
157
|
+
@doc.url = '123'
|
158
|
+
end
|
170
159
|
|
171
|
-
|
172
|
-
|
173
|
-
|
160
|
+
link = CommonMarker.render_doc('[GitHub](https://www.github.com)').first_child.first_child
|
161
|
+
assert_raises TypeError do
|
162
|
+
link.url = 123
|
163
|
+
end
|
174
164
|
end
|
175
165
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
166
|
+
def test_bad_title_get
|
167
|
+
assert_raises NodeError do
|
168
|
+
@doc.title
|
169
|
+
end
|
180
170
|
end
|
181
|
-
end
|
182
171
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
172
|
+
def test_bad_title_set
|
173
|
+
assert_raises NodeError do
|
174
|
+
@doc.title = '123'
|
175
|
+
end
|
188
176
|
|
189
|
-
|
190
|
-
|
191
|
-
|
177
|
+
image = CommonMarker.render_doc('![alt text](https://github.com/favicon.ico "Favicon")')
|
178
|
+
image = image.first_child.first_child
|
179
|
+
assert_raises TypeError do
|
180
|
+
image.title = 123
|
181
|
+
end
|
192
182
|
end
|
193
183
|
|
194
|
-
|
195
|
-
|
196
|
-
|
184
|
+
def test_bad_header_level_get
|
185
|
+
assert_raises NodeError do
|
186
|
+
@doc.header_level
|
187
|
+
end
|
197
188
|
end
|
198
|
-
end
|
199
189
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
end
|
190
|
+
def test_bad_header_level_set
|
191
|
+
assert_raises NodeError do
|
192
|
+
@doc.header_level = 1
|
193
|
+
end
|
205
194
|
|
206
|
-
|
207
|
-
|
208
|
-
|
195
|
+
header = CommonMarker.render_doc('### Header Three').first_child
|
196
|
+
assert_raises TypeError do
|
197
|
+
header.header_level = '123'
|
198
|
+
end
|
209
199
|
end
|
210
200
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
assert_raises TypeError do
|
216
|
-
ul_list.list_type = 1234
|
201
|
+
def test_bad_list_type_get
|
202
|
+
assert_raises NodeError do
|
203
|
+
@doc.list_type
|
204
|
+
end
|
217
205
|
end
|
218
|
-
end
|
219
206
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
end
|
207
|
+
def test_bad_list_type_set
|
208
|
+
assert_raises NodeError do
|
209
|
+
@doc.list_type = :bullet_list
|
210
|
+
end
|
225
211
|
|
226
|
-
|
227
|
-
|
228
|
-
|
212
|
+
ul_list = CommonMarker.render_doc("* Bullet\n*Bullet").first_child
|
213
|
+
assert_raises NodeError do
|
214
|
+
ul_list.list_type = :fake
|
215
|
+
end
|
216
|
+
assert_raises TypeError do
|
217
|
+
ul_list.list_type = 1234
|
218
|
+
end
|
229
219
|
end
|
230
220
|
|
231
|
-
|
232
|
-
|
233
|
-
|
221
|
+
def test_bad_list_start_get
|
222
|
+
assert_raises NodeError do
|
223
|
+
@doc.list_start
|
224
|
+
end
|
234
225
|
end
|
235
|
-
end
|
236
226
|
|
237
|
-
|
238
|
-
|
239
|
-
|
227
|
+
def test_bad_list_start_set
|
228
|
+
assert_raises NodeError do
|
229
|
+
@doc.list_start = 12
|
230
|
+
end
|
231
|
+
|
232
|
+
ol_list = CommonMarker.render_doc("1. One\n2. Two").first_child
|
233
|
+
assert_raises TypeError do
|
234
|
+
ol_list.list_start = :fake
|
235
|
+
end
|
240
236
|
end
|
241
|
-
end
|
242
237
|
|
243
|
-
|
244
|
-
|
245
|
-
|
238
|
+
def test_bad_list_tight_get
|
239
|
+
assert_raises NodeError do
|
240
|
+
@doc.list_tight
|
241
|
+
end
|
246
242
|
end
|
247
|
-
end
|
248
243
|
|
249
|
-
|
250
|
-
|
251
|
-
|
244
|
+
def test_bad_list_tight_set
|
245
|
+
assert_raises NodeError do
|
246
|
+
@doc.list_tight = false
|
247
|
+
end
|
252
248
|
end
|
253
|
-
end
|
254
249
|
|
255
|
-
|
256
|
-
|
257
|
-
|
250
|
+
def test_bad_fence_info_get
|
251
|
+
assert_raises NodeError do
|
252
|
+
@doc.fence_info
|
253
|
+
end
|
258
254
|
end
|
259
255
|
|
260
|
-
|
261
|
-
|
262
|
-
|
256
|
+
def test_bad_fence_info_set
|
257
|
+
assert_raises NodeError do
|
258
|
+
@doc.fence_info = 'ruby'
|
259
|
+
end
|
260
|
+
|
261
|
+
fence = CommonMarker.render_doc("``` ruby\nputs 'wow'\n```").first_child
|
262
|
+
assert_raises TypeError do
|
263
|
+
fence.fence_info = 123
|
264
|
+
end
|
263
265
|
end
|
264
266
|
end
|
265
267
|
end
|