commonmarker 0.20.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of commonmarker might be problematic. Click here for more details.

@@ -2,15 +2,9 @@
2
2
 
3
3
  module CommonMarker
4
4
  class HtmlRenderer < Renderer
5
- def render(node)
6
- super(node)
7
- end
8
-
9
5
  def document(_)
10
6
  super
11
- if @written_footnote_ix
12
- out("</ol>\n</section>\n")
13
- end
7
+ out("</ol>\n</section>\n") if @written_footnote_ix
14
8
  end
15
9
 
16
10
  def header(node)
@@ -71,12 +65,13 @@ module CommonMarker
71
65
 
72
66
  def tasklist(node)
73
67
  return '' unless tasklist?(node)
68
+
74
69
  state = if checked?(node)
75
- 'checked="" disabled=""'
76
- else
77
- 'disabled=""'
78
- end
79
- return "><input type=\"checkbox\" #{state} /"
70
+ 'checked="" disabled=""'
71
+ else
72
+ 'disabled=""'
73
+ end
74
+ "><input type=\"checkbox\" #{state} /"
80
75
  end
81
76
 
82
77
  def blockquote(node)
@@ -97,9 +92,7 @@ module CommonMarker
97
92
  block do
98
93
  if option_enabled?(:GITHUB_PRE_LANG)
99
94
  out("<pre#{sourcepos(node)}")
100
- if node.fence_info && !node.fence_info.empty?
101
- out(' lang="', node.fence_info.split(/\s+/)[0], '"')
102
- end
95
+ out(' lang="', node.fence_info.split(/\s+/)[0], '"') if node.fence_info && !node.fence_info.empty?
103
96
  out('><code>')
104
97
  else
105
98
  out("<pre#{sourcepos(node)}><code")
@@ -142,9 +135,7 @@ module CommonMarker
142
135
 
143
136
  def link(node)
144
137
  out('<a href="', node.url.nil? ? '' : escape_href(node.url), '"')
145
- if node.title && !node.title.empty?
146
- out(' title="', escape_html(node.title), '"')
147
- end
138
+ out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
148
139
  out('>', :children, '</a>')
149
140
  end
150
141
 
@@ -153,9 +144,7 @@ module CommonMarker
153
144
  plain do
154
145
  out(' alt="', :children, '"')
155
146
  end
156
- if node.title && !node.title.empty?
157
- out(' title="', escape_html(node.title), '"')
158
- end
147
+ out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
159
148
  out(' />')
160
149
  end
161
150
 
@@ -169,7 +158,7 @@ module CommonMarker
169
158
  out('</code>')
170
159
  end
171
160
 
172
- def linebreak(node)
161
+ def linebreak(_node)
173
162
  out("<br />\n")
174
163
  end
175
164
 
@@ -210,9 +199,9 @@ module CommonMarker
210
199
 
211
200
  def table_cell(node)
212
201
  align = case @alignments[@column_index]
213
- when :left; ' align="left"'
214
- when :right; ' align="right"'
215
- when :center; ' align="center"'
202
+ when :left then ' align="left"'
203
+ when :right then ' align="right"'
204
+ when :center then ' align="center"'
216
205
  else; ''
217
206
  end
218
207
  out(@in_header ? "<th#{align}#{sourcepos(node)}>" : "<td#{align}#{sourcepos(node)}>", :children, @in_header ? "</th>\n" : "</td>\n")
@@ -228,28 +217,27 @@ module CommonMarker
228
217
  end
229
218
 
230
219
  def footnote_definition(_)
231
- if !@footnote_ix
220
+ unless @footnote_ix
232
221
  out("<section class=\"footnotes\">\n<ol>\n")
233
222
  @footnote_ix = 0
234
223
  end
235
224
 
236
225
  @footnote_ix += 1
237
- out("<li id=\"fn#@footnote_ix\">\n", :children)
238
- if out_footnote_backref
239
- out("\n")
240
- end
226
+ out("<li id=\"fn#{@footnote_ix}\">\n", :children)
227
+ out("\n") if out_footnote_backref
241
228
  out("</li>\n")
242
- #</ol>
243
- #</section>
229
+ # </ol>
230
+ # </section>
244
231
  end
245
232
 
246
233
  private
247
234
 
248
235
  def out_footnote_backref
249
236
  return false if @written_footnote_ix == @footnote_ix
237
+
250
238
  @written_footnote_ix = @footnote_ix
251
239
 
252
- out("<a href=\"#fnref#@footnote_ix\" class=\"footnote-backref\">↩</a>")
240
+ out("<a href=\"#fnref#{@footnote_ix}\" class=\"footnote-backref\">↩</a>")
253
241
  true
254
242
  end
255
243
 
@@ -258,8 +246,7 @@ module CommonMarker
258
246
  end
259
247
 
260
248
  def checked?(node)
261
- node.tasklist_state == 'checked'
249
+ node.tasklist_item_checked?
262
250
  end
263
-
264
251
  end
265
252
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommonMarker
4
- VERSION = '0.20.1'.freeze
4
+ VERSION = '0.22.0'
5
5
  end
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 = %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('<p>I am <strong>strong</strong></p>', out)
9
+ end
10
+
11
+ def test_does_not_have_extensions
12
+ out = make_bin('table.md')
13
+ assert_includes out, '| a'
14
+ refute_includes out, '<p><del>hi</del>'
15
+ refute_includes out, '<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_includes out, '| a'
21
+ refute_includes out, '<p><del>hi</del>'
22
+ %w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert_includes out, html }
23
+ end
24
+
25
+ def test_understands_multiple_extensions
26
+ out = make_bin('table.md', '--extension=table,strikethrough')
27
+ refute_includes out, '| a'
28
+ assert_includes out, '<p><del>hi</del>'
29
+ %w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert_includes out, 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
 
@@ -30,7 +30,7 @@ Okay, _enough_.
30
30
  compare = render_doc(@markdown).to_commonmark
31
31
 
32
32
  assert_equal \
33
- render_doc(@markdown).to_html.gsub(/ +/, ' ').gsub(HTML_COMMENT, ''),
34
- render_doc(compare).to_html.gsub(/ +/, ' ').gsub(HTML_COMMENT, '')
33
+ render_doc(@markdown).to_html.squeeze(' ').gsub(HTML_COMMENT, ''),
34
+ render_doc(compare).to_html.squeeze(' ').gsub(HTML_COMMENT, '')
35
35
  end
36
36
  end
data/test/test_doc.rb CHANGED
@@ -17,114 +17,114 @@ class TestDocNode < Minitest::Test
17
17
  end
18
18
 
19
19
  def test_get_type
20
- assert_equal @doc.type, :document
20
+ assert_equal(:document, @doc.type)
21
21
  end
22
22
 
23
23
  def test_get_type_string
24
- assert_equal @doc.type_string, 'document'
24
+ assert_equal('document', @doc.type_string)
25
25
  end
26
26
 
27
27
  def test_get_first_child
28
- assert_equal @first_child.type, :paragraph
28
+ assert_equal(:paragraph, @first_child.type)
29
29
  end
30
30
 
31
31
  def test_get_next
32
- assert_equal @first_child.first_child.next.type, :emph
32
+ assert_equal(:emph, @first_child.first_child.next.type)
33
33
  end
34
34
 
35
35
  def test_insert_before
36
36
  paragraph = Node.new(:paragraph)
37
- assert_equal @first_child.insert_before(paragraph), true
37
+ assert(@first_child.insert_before(paragraph))
38
38
  assert_match "<p></p>\n<p>Hi <em>there</em>.", @doc.to_html
39
39
  end
40
40
 
41
41
  def test_insert_after
42
42
  paragraph = Node.new(:paragraph)
43
- assert_equal @first_child.insert_after(paragraph), true
43
+ assert(@first_child.insert_after(paragraph))
44
44
  assert_match "<strong>many nodes</strong>!</p>\n<p></p>\n", @doc.to_html
45
45
  end
46
46
 
47
47
  def test_prepend_child
48
48
  code = Node.new(:code)
49
- assert_equal @first_child.prepend_child(code), true
49
+ assert(@first_child.prepend_child(code))
50
50
  assert_match '<p><code></code>Hi <em>there</em>.', @doc.to_html
51
51
  end
52
52
 
53
53
  def test_append_child
54
54
  strong = Node.new(:strong)
55
- assert_equal @first_child.append_child(strong), true
55
+ assert(@first_child.append_child(strong))
56
56
  assert_match "!<strong></strong></p>\n", @doc.to_html
57
57
  end
58
58
 
59
59
  def test_get_last_child
60
- assert_equal @last_child.type, :paragraph
60
+ assert_equal(:paragraph, @last_child.type)
61
61
  end
62
62
 
63
63
  def test_get_parent
64
- assert_equal @first_child.first_child.next.parent.type, :paragraph
64
+ assert_equal(:paragraph, @first_child.first_child.next.parent.type)
65
65
  end
66
66
 
67
67
  def test_get_previous
68
- assert_equal @first_child.first_child.next.previous.type, :text
68
+ assert_equal(:text, @first_child.first_child.next.previous.type)
69
69
  end
70
70
 
71
71
  def test_get_url
72
- assert_equal @link.url, 'https://www.github.com'
72
+ assert_equal('https://www.github.com', @link.url)
73
73
  end
74
74
 
75
75
  def test_set_url
76
- assert_equal @link.url = 'https://www.mozilla.org', 'https://www.mozilla.org'
76
+ assert_equal('https://www.mozilla.org', @link.url = 'https://www.mozilla.org')
77
77
  end
78
78
 
79
79
  def test_get_title
80
- assert_equal @image.title, 'Favicon'
80
+ assert_equal('Favicon', @image.title)
81
81
  end
82
82
 
83
83
  def test_set_title
84
- assert_equal @image.title = 'Octocat', 'Octocat'
84
+ assert_equal('Octocat', @image.title = 'Octocat')
85
85
  end
86
86
 
87
87
  def test_get_header_level
88
- assert_equal @header.header_level, 3
88
+ assert_equal(3, @header.header_level)
89
89
  end
90
90
 
91
91
  def test_set_header_level
92
- assert_equal @header.header_level = 6, 6
92
+ assert_equal(6, @header.header_level = 6)
93
93
  end
94
94
 
95
95
  def test_get_list_type
96
- assert_equal @ul_list.list_type, :bullet_list
97
- assert_equal @ol_list.list_type, :ordered_list
96
+ assert_equal(:bullet_list, @ul_list.list_type)
97
+ assert_equal(:ordered_list, @ol_list.list_type)
98
98
  end
99
99
 
100
100
  def test_set_list_type
101
- assert_equal @ul_list.list_type = :ordered_list, :ordered_list
102
- assert_equal @ol_list.list_type = :bullet_list, :bullet_list
101
+ assert_equal(:ordered_list, @ul_list.list_type = :ordered_list)
102
+ assert_equal(:bullet_list, @ol_list.list_type = :bullet_list)
103
103
  end
104
104
 
105
105
  def test_get_list_start
106
- assert_equal @ol_list.list_start, 1
106
+ assert_equal(1, @ol_list.list_start)
107
107
  end
108
108
 
109
109
  def test_set_list_start
110
- assert_equal @ol_list.list_start = 8, 8
110
+ assert_equal(8, @ol_list.list_start = 8)
111
111
  end
112
112
 
113
113
  def test_get_list_tight
114
- assert_equal @ul_list.list_tight, true
115
- assert_equal @ol_list.list_tight, true
114
+ assert(@ul_list.list_tight)
115
+ assert(@ol_list.list_tight)
116
116
  end
117
117
 
118
118
  def test_set_list_tight
119
- assert_equal @ul_list.list_tight = false, false
120
- assert_equal @ol_list.list_tight = false, false
119
+ refute(@ul_list.list_tight = false)
120
+ refute(@ol_list.list_tight = false)
121
121
  end
122
122
 
123
123
  def test_get_fence_info
124
- assert_equal @fence.fence_info, 'ruby'
124
+ assert_equal('ruby', @fence.fence_info)
125
125
  end
126
126
 
127
127
  def test_set_fence_info
128
- assert_equal @fence.fence_info = 'javascript', 'javascript'
128
+ assert_equal('javascript', @fence.fence_info = 'javascript')
129
129
  end
130
130
  end
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'test_helper'
@@ -6,16 +5,16 @@ 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
- assert_equal render.rstrip, '<p>This curly quote “makes commonmarker throw an exception”.</p>'
11
+ assert_equal('<p>This curly quote “makes commonmarker throw an exception”.</p>', render.rstrip)
13
12
  end
14
13
 
15
14
  def test_string_content_is_utf8
16
15
  doc = CommonMarker.render_doc('Hi *there*')
17
16
  text = doc.first_child.last_child.first_child
18
- assert_equal text.string_content, 'there'
19
- assert_equal text.string_content.encoding.name, 'UTF-8'
17
+ assert_equal('there', text.string_content)
18
+ assert_equal('UTF-8', text.string_content.encoding.name)
20
19
  end
21
20
  end
@@ -4,67 +4,55 @@ 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
22
11
  CommonMarker.render_html(@markdown, :DEFAULT, %i[]).tap do |out|
23
- assert out.include?('| a')
24
- assert out.include?('| <strong>x</strong>')
25
- assert out.include?('~~hi~~')
12
+ assert_includes out, '| a'
13
+ assert_includes out, '| <strong>x</strong>'
14
+ assert_includes out, '~~hi~~'
26
15
  end
27
16
 
28
17
  CommonMarker.render_html(@markdown, :DEFAULT, %i[table]).tap do |out|
29
- refute out.include?('| a')
30
- %w(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each { |html| assert out.include?(html) }
31
- assert out.include?('~~hi~~')
18
+ refute_includes out, '| a'
19
+ %w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert_includes out, html }
20
+ assert_includes out, '~~hi~~'
32
21
  end
33
22
 
34
23
  CommonMarker.render_html(@markdown, :DEFAULT, %i[strikethrough]).tap do |out|
35
- assert out.include?('| a')
36
- refute out.include?('~~hi~~')
37
- assert out.include?('<del>hi</del>')
24
+ assert_includes out, '| a'
25
+ refute_includes out, '~~hi~~'
26
+ assert_includes out, '<del>hi</del>'
38
27
  end
39
28
 
40
29
  doc = CommonMarker.render_doc('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
41
- assert_equal doc.to_html, "<p>~a~ <del>b</del> ~~~c~~~</p>\n"
30
+ assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", doc.to_html)
42
31
 
43
32
  CommonMarker.render_html(@markdown, :DEFAULT, %i[table strikethrough]).tap do |out|
44
- refute out.include?('| a')
45
- refute out.include?('| <strong>x</strong>')
46
- refute out.include?('~~hi~~')
33
+ refute_includes out, '| a'
34
+ refute_includes out, '| <strong>x</strong>'
35
+ refute_includes out, '~~hi~~'
47
36
  end
48
-
49
37
  end
50
38
 
51
39
  def test_extensions_with_renderers
52
40
  doc = CommonMarker.render_doc(@markdown, :DEFAULT, %i[table])
53
41
 
54
42
  doc.to_html.tap do |out|
55
- refute out.include?('| a')
56
- %w(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each { |html| assert out.include?(html) }
57
- assert out.include?('~~hi~~')
43
+ refute_includes out, '| a'
44
+ %w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert_includes out, html }
45
+ assert_includes out, '~~hi~~'
58
46
  end
59
47
 
60
48
  HtmlRenderer.new.render(doc).tap do |out|
61
- refute out.include?('| a')
62
- %w(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each { |html| assert out.include?(html) }
63
- assert out.include?('~~hi~~')
49
+ refute_includes out, '| a'
50
+ %w[<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>].each { |html| assert_includes out, html }
51
+ assert_includes out, '~~hi~~'
64
52
  end
65
53
 
66
54
  doc = CommonMarker.render_doc('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
67
- assert_equal HtmlRenderer.new.render(doc), "<p>~a~ <del>b</del> ~~~c~~~</p>\n"
55
+ assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", HtmlRenderer.new.render(doc))
68
56
  end
69
57
 
70
58
  def test_bad_extension_specifications
@@ -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