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.

Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +2 -3
  3. data/Rakefile +16 -4
  4. data/bin/commonmarker +82 -44
  5. data/commonmarker.gemspec +9 -12
  6. data/ext/commonmarker/blocks.c +89 -29
  7. data/ext/commonmarker/buffer.c +0 -1
  8. data/ext/commonmarker/chunk.h +0 -1
  9. data/ext/commonmarker/cmark-gfm-core-extensions.h +24 -1
  10. data/ext/commonmarker/cmark-gfm.h +14 -8
  11. data/ext/commonmarker/cmark-gfm_version.h +2 -2
  12. data/ext/commonmarker/commonmark.c +9 -4
  13. data/ext/commonmarker/commonmarker.c +120 -78
  14. data/ext/commonmarker/html.c +4 -4
  15. data/ext/commonmarker/inlines.c +21 -14
  16. data/ext/commonmarker/iterator.h +0 -1
  17. data/ext/commonmarker/map.h +0 -1
  18. data/ext/commonmarker/node.h +2 -0
  19. data/ext/commonmarker/parser.h +2 -1
  20. data/ext/commonmarker/render.c +16 -14
  21. data/ext/commonmarker/render.h +0 -1
  22. data/ext/commonmarker/scanners.c +777 -951
  23. data/ext/commonmarker/scanners.h +0 -2
  24. data/ext/commonmarker/table.c +52 -13
  25. data/ext/commonmarker/tasklist.c +34 -13
  26. data/lib/commonmarker.rb +5 -4
  27. data/lib/commonmarker/config.rb +5 -4
  28. data/lib/commonmarker/node.rb +1 -1
  29. data/lib/commonmarker/node/inspect.rb +12 -12
  30. data/lib/commonmarker/renderer.rb +7 -7
  31. data/lib/commonmarker/renderer/html_renderer.rb +22 -35
  32. data/lib/commonmarker/version.rb +1 -1
  33. data/test/benchmark.rb +1 -5
  34. data/test/fixtures/strong.md +1 -0
  35. data/test/fixtures/table.md +10 -0
  36. data/test/test_attributes.rb +3 -3
  37. data/test/test_commands.rb +31 -0
  38. data/test/test_commonmark.rb +11 -11
  39. data/test/test_encoding.rb +1 -2
  40. data/test/test_extensions.rb +40 -52
  41. data/test/test_footnotes.rb +9 -9
  42. data/test/test_gc.rb +2 -0
  43. data/test/test_helper.rb +15 -8
  44. data/test/test_maliciousness.rb +192 -190
  45. data/test/test_node.rb +10 -12
  46. data/test/test_options.rb +15 -15
  47. data/test/test_pathological_inputs.rb +2 -2
  48. data/test/test_plaintext.rb +21 -21
  49. data/test/test_renderer.rb +9 -9
  50. data/test/test_spec.rb +3 -2
  51. data/test/test_tasklists.rb +22 -6
  52. metadata +51 -46
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommonMarker
4
- VERSION = '0.19.0'.freeze
4
+ VERSION = '0.21.1'
5
5
  end
@@ -13,16 +13,12 @@ end
13
13
 
14
14
  benchinput = File.open('test/benchinput.md', 'r').read
15
15
 
16
- printf("input size = %d bytes\n\n", benchinput.bytesize)
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**
@@ -0,0 +1,10 @@
1
+ One extension:
2
+
3
+ | a | b |
4
+ | --- | --- |
5
+ | c | d |
6
+ | **x** | |
7
+
8
+ Another extension:
9
+
10
+ ~~hi~~
@@ -4,7 +4,7 @@ require 'test_helper'
4
4
 
5
5
  class TestAttributes < Minitest::Test
6
6
  def setup
7
- contents = File.read(File.join(FIXTURES_DIR, 'dingus.md'))
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? { |v| v == 0 } }
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
@@ -3,22 +3,22 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class TestCommonmark < Minitest::Test
6
- HTML_COMMENT = %r[<!--.*?-->\s?]
6
+ HTML_COMMENT = /<!--.*?-->\s?/.freeze
7
7
 
8
8
  def setup
9
- @markdown = <<-MD
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
 
@@ -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 = File.read(File.join(FIXTURES_DIR, 'curly.md'), encoding: 'utf-8')
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>'
@@ -4,18 +4,7 @@ require 'test_helper'
4
4
 
5
5
  class TestExtensions < Minitest::Test
6
6
  def setup
7
- @markdown = <<-MD
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(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each { |html| assert out.include?(html) }
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(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each { |html| assert out.include?(html) }
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(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each { |html| assert out.include?(html) }
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> &lt;xmp>\n",
78
- CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :UNSAFE, %i[tagfilter])
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
- assert_equal(<<-HTML, CommonMarker.render_html(<<-MD, :TABLE_PREFER_STYLE_ATTRIBUTES, %i[table]))
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
- HTML
104
- aaa | bbb | ccc | ddd | eee
105
- :-- | --- | :-: | --- | --:
106
- fff | ggg | hhh | iii | jjj
107
- MD
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(<<-HTML, CommonMarker.render_doc(<<-MD, :DEFAULT, %i[table strikethrough]).to_plaintext)
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
@@ -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 = <<-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>
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
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Lint/UselessAssignment
3
4
  require 'test_helper'
4
5
 
5
6
  class TestNode < Minitest::Test
@@ -43,3 +44,4 @@ class TestNode < Minitest::Test
43
44
  # free.
44
45
  end
45
46
  end
47
+ # rubocop:enable Lint/UselessAssignment
@@ -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 = $1.split
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 == 0
55
- markdown_lines << "#{line}"
61
+ start_line = line_number - 1 if start_line.zero?
62
+ markdown_lines << line.to_s
56
63
  elsif state == 2
57
- html_lines << "#{line}"
58
- elsif state == 0 && header_re.match(line)
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
@@ -2,264 +2,266 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class CommonMarker::TestMaliciousness < Minitest::Test
6
- def setup
7
- @doc = CommonMarker.render_doc('Hi *there*')
8
- end
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
- assert_raises NodeError do
16
- Node.new(:totes_fake)
17
- end
11
+ def test_init_with_bad_type
12
+ assert_raises TypeError do
13
+ Node.new(123)
14
+ end
18
15
 
19
- assert_raises TypeError do
20
- Node.new([])
21
- end
16
+ assert_raises NodeError do
17
+ Node.new(:totes_fake)
18
+ end
22
19
 
23
- assert_raises TypeError do
24
- Node.new([23])
25
- end
20
+ assert_raises TypeError do
21
+ Node.new([])
22
+ end
26
23
 
27
- assert_raises TypeError do
28
- Node.new(nil)
29
- end
30
- end
24
+ assert_raises TypeError do
25
+ Node.new([23])
26
+ end
31
27
 
32
- def test_rendering_with_bad_type
33
- assert_raises TypeError do
34
- CommonMarker.render_html("foo \n baz", 123)
28
+ assert_raises TypeError do
29
+ Node.new(nil)
30
+ end
35
31
  end
36
32
 
37
- assert_raises TypeError do
38
- CommonMarker.render_html("foo \n baz", :totes_fake)
39
- end
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
- assert_raises TypeError do
42
- CommonMarker.render_html("foo \n baz", [])
43
- end
38
+ assert_raises TypeError do
39
+ CommonMarker.render_html("foo \n baz", :totes_fake)
40
+ end
44
41
 
45
- assert_raises TypeError do
46
- CommonMarker.render_html("foo \n baz", [23])
47
- end
42
+ assert_raises TypeError do
43
+ CommonMarker.render_html("foo \n baz", [])
44
+ end
48
45
 
49
- assert_raises TypeError do
50
- CommonMarker.render_html("foo \n baz", nil)
51
- end
46
+ assert_raises TypeError do
47
+ CommonMarker.render_html("foo \n baz", [23])
48
+ end
52
49
 
53
- assert_raises TypeError do
54
- CommonMarker.render_html("foo \n baz", [:SMART, 'totes_fake'])
55
- end
50
+ assert_raises TypeError do
51
+ CommonMarker.render_html("foo \n baz", nil)
52
+ end
56
53
 
57
- assert_raises TypeError do
58
- CommonMarker.render_html(123)
59
- end
54
+ assert_raises TypeError do
55
+ CommonMarker.render_html("foo \n baz", [:SMART, 'totes_fake'])
56
+ end
60
57
 
61
- assert_raises TypeError do
62
- CommonMarker.render_html([123])
63
- end
58
+ assert_raises TypeError do
59
+ CommonMarker.render_html(123)
60
+ end
64
61
 
65
- assert_raises TypeError do
66
- CommonMarker.render_html(nil)
67
- end
62
+ assert_raises TypeError do
63
+ CommonMarker.render_html([123])
64
+ end
68
65
 
69
- err = assert_raises TypeError do
70
- CommonMarker.render_html("foo \n baz", [:SMART])
71
- end
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
- assert_raises TypeError do
75
- CommonMarker.render_doc("foo \n baz", 123)
76
- end
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
- err = assert_raises TypeError do
79
- CommonMarker.render_doc("foo \n baz", :safe)
80
- end
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
- assert_raises TypeError do
84
- CommonMarker.render_doc("foo \n baz", :totes_fake)
85
- end
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
- assert_raises TypeError do
88
- CommonMarker.render_doc("foo \n baz", [])
89
- end
84
+ assert_raises TypeError do
85
+ CommonMarker.render_doc("foo \n baz", :totes_fake)
86
+ end
90
87
 
91
- assert_raises TypeError do
92
- CommonMarker.render_doc("foo \n baz", [23])
93
- end
88
+ assert_raises TypeError do
89
+ CommonMarker.render_doc("foo \n baz", [])
90
+ end
94
91
 
95
- assert_raises TypeError do
96
- CommonMarker.render_doc("foo \n baz", nil)
97
- end
92
+ assert_raises TypeError do
93
+ CommonMarker.render_doc("foo \n baz", [23])
94
+ end
98
95
 
99
- assert_raises TypeError do
100
- CommonMarker.render_doc("foo \n baz", [:SMART, 'totes_fake'])
101
- end
96
+ assert_raises TypeError do
97
+ CommonMarker.render_doc("foo \n baz", nil)
98
+ end
102
99
 
103
- assert_raises TypeError do
104
- CommonMarker.render_doc(123)
105
- end
100
+ assert_raises TypeError do
101
+ CommonMarker.render_doc("foo \n baz", [:SMART, 'totes_fake'])
102
+ end
106
103
 
107
- assert_raises TypeError do
108
- CommonMarker.render_doc([123])
109
- end
104
+ assert_raises TypeError do
105
+ CommonMarker.render_doc(123)
106
+ end
110
107
 
111
- assert_raises TypeError do
112
- CommonMarker.render_doc(nil)
113
- end
114
- end
108
+ assert_raises TypeError do
109
+ CommonMarker.render_doc([123])
110
+ end
115
111
 
116
- def test_bad_set_string_content
117
- assert_raises TypeError do
118
- @doc.string_content = 123
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
- def test_bad_insertion
128
- code = Node.new(:code)
129
- assert_raises NodeError do
130
- @doc.insert_before(code)
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
- paragraph = Node.new(:paragraph)
134
- assert_raises NodeError do
135
- @doc.insert_after(paragraph)
123
+ def test_bad_walking
124
+ assert_nil @doc.parent
125
+ assert_nil @doc.previous
136
126
  end
137
127
 
138
- document = Node.new(:document)
139
- assert_raises NodeError do
140
- @doc.prepend_child(document)
141
- end
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
- assert_raises NodeError do
144
- @doc.append_child(document)
145
- end
146
- end
134
+ paragraph = Node.new(:paragraph)
135
+ assert_raises NodeError do
136
+ @doc.insert_after(paragraph)
137
+ end
147
138
 
148
- def test_bad_url_get
149
- assert_raises NodeError do
150
- @doc.url
151
- end
152
- end
139
+ document = Node.new(:document)
140
+ assert_raises NodeError do
141
+ @doc.prepend_child(document)
142
+ end
153
143
 
154
- def test_bad_url_set
155
- assert_raises NodeError do
156
- @doc.url = '123'
144
+ assert_raises NodeError do
145
+ @doc.append_child(document)
146
+ end
157
147
  end
158
148
 
159
- link = CommonMarker.render_doc('[GitHub](https://www.github.com)').first_child.first_child
160
- assert_raises TypeError do
161
- link.url = 123
149
+ def test_bad_url_get
150
+ assert_raises NodeError do
151
+ @doc.url
152
+ end
162
153
  end
163
- end
164
154
 
165
- def test_bad_title_get
166
- assert_raises NodeError do
167
- @doc.title
168
- end
169
- end
155
+ def test_bad_url_set
156
+ assert_raises NodeError do
157
+ @doc.url = '123'
158
+ end
170
159
 
171
- def test_bad_title_set
172
- assert_raises NodeError do
173
- @doc.title = '123'
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
- image = CommonMarker.render_doc('![alt text](https://github.com/favicon.ico "Favicon")')
177
- image = image.first_child.first_child
178
- assert_raises TypeError do
179
- image.title = 123
166
+ def test_bad_title_get
167
+ assert_raises NodeError do
168
+ @doc.title
169
+ end
180
170
  end
181
- end
182
171
 
183
- def test_bad_header_level_get
184
- assert_raises NodeError do
185
- @doc.header_level
186
- end
187
- end
172
+ def test_bad_title_set
173
+ assert_raises NodeError do
174
+ @doc.title = '123'
175
+ end
188
176
 
189
- def test_bad_header_level_set
190
- assert_raises NodeError do
191
- @doc.header_level = 1
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
- header = CommonMarker.render_doc('### Header Three').first_child
195
- assert_raises TypeError do
196
- header.header_level = '123'
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
- def test_bad_list_type_get
201
- assert_raises NodeError do
202
- @doc.list_type
203
- end
204
- end
190
+ def test_bad_header_level_set
191
+ assert_raises NodeError do
192
+ @doc.header_level = 1
193
+ end
205
194
 
206
- def test_bad_list_type_set
207
- assert_raises NodeError do
208
- @doc.list_type = :bullet_list
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
- ul_list = CommonMarker.render_doc("* Bullet\n*Bullet").first_child
212
- assert_raises NodeError do
213
- ul_list.list_type = :fake
214
- end
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
- def test_bad_list_start_get
221
- assert_raises NodeError do
222
- @doc.list_start
223
- end
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
- def test_bad_list_start_set
227
- assert_raises NodeError do
228
- @doc.list_start = 12
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
- ol_list = CommonMarker.render_doc("1. One\n2. Two").first_child
232
- assert_raises TypeError do
233
- ol_list.list_start = :fake
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
- def test_bad_list_tight_get
238
- assert_raises NodeError do
239
- @doc.list_tight
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
- def test_bad_list_tight_set
244
- assert_raises NodeError do
245
- @doc.list_tight = false
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
- def test_bad_fence_info_get
250
- assert_raises NodeError do
251
- @doc.fence_info
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
- def test_bad_fence_info_set
256
- assert_raises NodeError do
257
- @doc.fence_info = 'ruby'
250
+ def test_bad_fence_info_get
251
+ assert_raises NodeError do
252
+ @doc.fence_info
253
+ end
258
254
  end
259
255
 
260
- fence = CommonMarker.render_doc("``` ruby\nputs 'wow'\n```").first_child
261
- assert_raises TypeError do
262
- fence.fence_info = 123
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