commonmarker 0.20.2 → 0.21.0

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.

@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommonMarker
4
- VERSION = '0.20.2'.freeze
4
+ VERSION = '0.21.0'
5
5
  end
@@ -13,7 +13,7 @@ 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)
@@ -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
@@ -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'
@@ -16,7 +16,7 @@ class TestExtensions < Minitest::Test
16
16
 
17
17
  CommonMarker.render_html(@markdown, :DEFAULT, %i[table]).tap do |out|
18
18
  refute out.include?('| a')
19
- %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) }
20
20
  assert out.include?('~~hi~~')
21
21
  end
22
22
 
@@ -34,7 +34,6 @@ class TestExtensions < Minitest::Test
34
34
  refute out.include?('| <strong>x</strong>')
35
35
  refute out.include?('~~hi~~')
36
36
  end
37
-
38
37
  end
39
38
 
40
39
  def test_extensions_with_renderers
@@ -42,13 +41,13 @@ class TestExtensions < Minitest::Test
42
41
 
43
42
  doc.to_html.tap do |out|
44
43
  refute out.include?('| a')
45
- %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) }
46
45
  assert out.include?('~~hi~~')
47
46
  end
48
47
 
49
48
  HtmlRenderer.new.render(doc).tap do |out|
50
49
  refute out.include?('| a')
51
- %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) }
52
51
  assert out.include?('~~hi~~')
53
52
  end
54
53
 
@@ -64,51 +63,51 @@ class TestExtensions < Minitest::Test
64
63
 
65
64
  def test_comments_are_kept_as_expected
66
65
  assert_equal "<!--hello--> <blah> &lt;xmp>\n",
67
- CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :UNSAFE, %i[tagfilter])
66
+ CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :UNSAFE, %i[tagfilter])
68
67
  end
69
68
 
70
69
  def test_table_prefer_style_attributes
71
- assert_equal(<<-HTML, CommonMarker.render_html(<<-MD, :TABLE_PREFER_STYLE_ATTRIBUTES, %i[table]))
72
- <table>
73
- <thead>
74
- <tr>
75
- <th style="text-align: left">aaa</th>
76
- <th>bbb</th>
77
- <th style="text-align: center">ccc</th>
78
- <th>ddd</th>
79
- <th style="text-align: right">eee</th>
80
- </tr>
81
- </thead>
82
- <tbody>
83
- <tr>
84
- <td style="text-align: left">fff</td>
85
- <td>ggg</td>
86
- <td style="text-align: center">hhh</td>
87
- <td>iii</td>
88
- <td style="text-align: right">jjj</td>
89
- </tr>
90
- </tbody>
91
- </table>
92
- HTML
93
- aaa | bbb | ccc | ddd | eee
94
- :-- | --- | :-: | --- | --:
95
- fff | ggg | hhh | iii | jjj
96
- 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
97
96
  end
98
97
 
99
98
  def test_plaintext
100
- assert_equal(<<-HTML, CommonMarker.render_doc(<<-MD, :DEFAULT, %i[table strikethrough]).to_plaintext)
101
- Hello ~there~.
99
+ assert_equal(<<~HTML, CommonMarker.render_doc(<<~MD, :DEFAULT, %i[table strikethrough]).to_plaintext)
100
+ Hello ~there~.
102
101
 
103
- | a |
104
- | --- |
105
- | b |
102
+ | a |
103
+ | --- |
104
+ | b |
106
105
  HTML
107
- Hello ~~there~~.
106
+ Hello ~~there~~.
108
107
 
109
- | a |
110
- | - |
111
- | b |
108
+ | a |
109
+ | - |
110
+ | b |
112
111
  MD
113
112
  end
114
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,7 +5,7 @@ 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
 
@@ -39,7 +38,7 @@ def open_spec_file(filename)
39
38
  l = line.strip
40
39
  if l =~ /^`{32} example(.*)$/
41
40
  state = 1
42
- extensions = $1.split
41
+ extensions = Regexp.last_match(1).split
43
42
  elsif l == '`' * 32
44
43
  state = 0
45
44
  example_number += 1
@@ -51,7 +50,7 @@ def open_spec_file(filename)
51
50
  start_line: start_line,
52
51
  end_line: end_line,
53
52
  section: headertext,
54
- extensions: extensions.map(&:to_sym),
53
+ extensions: extensions.map(&:to_sym)
55
54
  }
56
55
  start_line = 0
57
56
  markdown_lines = []
@@ -59,11 +58,11 @@ def open_spec_file(filename)
59
58
  elsif l == '.'
60
59
  state = 2
61
60
  elsif state == 1
62
- start_line = line_number - 1 if start_line == 0
63
- markdown_lines << "#{line}"
61
+ start_line = line_number - 1 if start_line.zero?
62
+ markdown_lines << line.to_s
64
63
  elsif state == 2
65
- html_lines << "#{line}"
66
- elsif state == 0 && header_re.match(line)
64
+ html_lines << line.to_s
65
+ elsif state.zero? && header_re.match(line)
67
66
  headertext = line.sub(header_re, '').strip
68
67
  end
69
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