kramdown 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +3 -2
  3. data/README.md +3 -3
  4. data/Rakefile +2 -1
  5. data/VERSION +1 -1
  6. data/bin/kramdown +4 -2
  7. data/doc/documentation.template +1 -0
  8. data/doc/index.page +2 -2
  9. data/doc/syntax.page +7 -7
  10. data/lib/kramdown/converter.rb +1 -0
  11. data/lib/kramdown/converter/man.rb +303 -0
  12. data/lib/kramdown/converter/math_engine/mathjax.rb +12 -2
  13. data/lib/kramdown/parser/gfm.rb +23 -6
  14. data/lib/kramdown/parser/kramdown/list.rb +4 -2
  15. data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
  16. data/lib/kramdown/parser/kramdown/table.rb +3 -3
  17. data/lib/kramdown/version.rb +1 -1
  18. data/man/man1/kramdown.1 +332 -472
  19. data/test/test_files.rb +15 -0
  20. data/test/testcases/block/08_list/lazy_and_nested.html +9 -0
  21. data/test/testcases/block/08_list/lazy_and_nested.text +4 -0
  22. data/test/testcases/block/14_table/header.html +21 -0
  23. data/test/testcases/block/14_table/header.text +7 -0
  24. data/test/testcases/block/15_math/mathjax_preview_as_code.html +4 -0
  25. data/test/testcases/block/15_math/mathjax_preview_as_code.options +3 -0
  26. data/test/testcases/block/15_math/mathjax_preview_as_code.text +5 -0
  27. data/test/testcases/man/example.man +123 -0
  28. data/test/testcases/man/example.text +85 -0
  29. data/test/testcases/man/heading-name-dash-description.man +4 -0
  30. data/test/testcases/man/heading-name-dash-description.text +1 -0
  31. data/test/testcases/man/heading-name-description.man +4 -0
  32. data/test/testcases/man/heading-name-description.text +2 -0
  33. data/test/testcases/man/heading-name-section-description.man +4 -0
  34. data/test/testcases/man/heading-name-section-description.text +1 -0
  35. data/test/testcases/man/heading-name-section.man +2 -0
  36. data/test/testcases/man/heading-name-section.text +1 -0
  37. data/test/testcases/man/heading-name.man +2 -0
  38. data/test/testcases/man/heading-name.text +1 -0
  39. data/test/testcases/man/sections.man +4 -0
  40. data/test/testcases/man/sections.text +11 -0
  41. data/test/testcases/man/text-escaping.man +8 -0
  42. data/test/testcases/man/text-escaping.text +7 -0
  43. data/test/testcases/span/text_substitutions/typography.html +2 -0
  44. data/test/testcases/span/text_substitutions/typography.text +2 -0
  45. data/test/testcases_gfm/codeblock_fenced.html +20 -0
  46. data/test/testcases_gfm/codeblock_fenced.options +1 -0
  47. data/test/testcases_gfm/codeblock_fenced.text +21 -0
  48. data/test/testcases_gfm/header_ids.html +17 -0
  49. data/test/testcases_gfm/header_ids.html.19 +17 -0
  50. data/test/testcases_gfm/header_ids.options +1 -0
  51. data/test/testcases_gfm/header_ids.text +17 -0
  52. data/test/testcases_gfm/header_ids_with_prefix.html +3 -0
  53. data/test/testcases_gfm/header_ids_with_prefix.options +2 -0
  54. data/test/testcases_gfm/header_ids_with_prefix.text +3 -0
  55. metadata +34 -2
@@ -82,6 +82,7 @@ class TestFiles < Minitest::Test
82
82
  'test/testcases/span/math/mathjaxnode.html', # bc of tidy
83
83
  'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
84
84
  'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
85
+ 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview
85
86
  'test/testcases/span/05_html/mark_element.html', # bc of tidy
86
87
  'test/testcases/block/09_html/xml.html', # bc of tidy
87
88
  'test/testcases/span/05_html/xml.html', # bc of tidy
@@ -241,6 +242,7 @@ class TestFiles < Minitest::Test
241
242
  'test/testcases/span/math/mathjaxnode.html', # bc of tidy
242
243
  'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
243
244
  'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
245
+ 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview
244
246
  'test/testcases/span/01_link/link_defs_with_ial.html', # bc of attribute ordering
245
247
  'test/testcases/span/05_html/mark_element.html', # bc of tidy
246
248
  'test/testcases/block/09_html/xml.html', # bc of tidy
@@ -261,12 +263,23 @@ class TestFiles < Minitest::Test
261
263
  end
262
264
  end
263
265
 
266
+ # Generate test methods for text-manpage conversion
267
+ Dir[File.dirname(__FILE__) + '/testcases/man/**/*.text'].each do |text_file|
268
+ define_method('test_' + text_file.tr('.', '_') + "_to_man") do
269
+ man_file = text_file.sub(/\.text$/, '.man')
270
+ doc = Kramdown::Document.new(File.read(text_file))
271
+ assert_equal(File.read(man_file), doc.to_man)
272
+ end
273
+ end
274
+
264
275
  EXCLUDE_GFM_FILES = [
265
276
  'test/testcases/block/03_paragraph/no_newline_at_end.text',
266
277
  'test/testcases/block/03_paragraph/indented.text',
267
278
  'test/testcases/block/03_paragraph/two_para.text',
268
279
  'test/testcases/block/04_header/atx_header.text',
269
280
  'test/testcases/block/04_header/setext_header.text',
281
+ 'test/testcases/block/04_header/with_auto_ids.text', # bc of ID generation difference
282
+ 'test/testcases/block/04_header/with_auto_id_prefix.text', # bc of ID generation difference
270
283
  'test/testcases/block/05_blockquote/indented.text',
271
284
  'test/testcases/block/05_blockquote/lazy.text',
272
285
  'test/testcases/block/05_blockquote/nested.text',
@@ -280,6 +293,7 @@ class TestFiles < Minitest::Test
280
293
  'test/testcases/block/08_list/other_first_element.text',
281
294
  'test/testcases/block/08_list/simple_ul.text',
282
295
  'test/testcases/block/08_list/special_cases.text',
296
+ 'test/testcases/block/08_list/lazy_and_nested.text', # bc of change in lazy line handling
283
297
  'test/testcases/block/09_html/comment.text',
284
298
  'test/testcases/block/09_html/html_to_native/code.text',
285
299
  'test/testcases/block/09_html/html_to_native/emphasis.text',
@@ -298,6 +312,7 @@ class TestFiles < Minitest::Test
298
312
  'test/testcases/block/14_table/escaping.text',
299
313
  'test/testcases/block/14_table/simple.text',
300
314
  'test/testcases/block/15_math/normal.text',
315
+ 'test/testcases/block/16_toc/toc_with_footnotes.text', # bc of ID generation difference
301
316
  'test/testcases/encoding.text',
302
317
  'test/testcases/span/01_link/inline.text',
303
318
  'test/testcases/span/01_link/link_defs.text',
@@ -0,0 +1,9 @@
1
+ <ol>
2
+ <li>Root level
3
+ * Second level
4
+ <ul>
5
+ <li>Third level
6
+ * Back to second level</li>
7
+ </ul>
8
+ </li>
9
+ </ol>
@@ -0,0 +1,4 @@
1
+ 1. Root level
2
+ * Second level
3
+ * Third level
4
+ * Back to second level
@@ -94,3 +94,24 @@
94
94
  </tr>
95
95
  </tbody>
96
96
  </table>
97
+
98
+ <p>Sep line with tab</p>
99
+
100
+ <table>
101
+ <thead>
102
+ <tr>
103
+ <th style="text-align: right">right</th>
104
+ <th style="text-align: center">center</th>
105
+ </tr>
106
+ </thead>
107
+ <tbody>
108
+ <tr>
109
+ <td style="text-align: right">cell1</td>
110
+ <td style="text-align: center">cell2</td>
111
+ </tr>
112
+ <tr>
113
+ <td style="text-align: right">cell3</td>
114
+ <td style="text-align: center">cell4</td>
115
+ </tr>
116
+ </tbody>
117
+ </table>
@@ -30,3 +30,10 @@ Multiple bodies
30
30
  | cell3 | cell4
31
31
  |----|||
32
32
  | cell5 | cell6
33
+
34
+ Sep line with tab
35
+
36
+ right | center
37
+ ---: | :---:
38
+ cell1 | cell2
39
+ cell3 | cell4
@@ -0,0 +1,4 @@
1
+ <p>This is a <code class="MathJax_Preview">5 + 5</code><script type="math/tex">5 + 5</script> statement</p>
2
+
3
+ <pre class="MathJax_Preview"><code>5 + 5</code></pre>
4
+ <script type="math/tex; mode=display">5 + 5</script>
@@ -0,0 +1,3 @@
1
+ :math_engine_opts:
2
+ :preview: true
3
+ :preview_as_code: true
@@ -0,0 +1,5 @@
1
+ This is a $$5 + 5$$ statement
2
+
3
+ $$
4
+ 5 + 5
5
+ $$
@@ -0,0 +1,123 @@
1
+ .\" generated by kramdown
2
+ .TH "NAME" "1" "November 2016" "Some extra data"
3
+ .SH NAME
4
+ name \- description
5
+ .SH "SYNOPSIS"
6
+ \fBname\fP [\fBOPTIONS\fP] \fIarguments\fP\.\.\.
7
+ .SH "DESCRIPTION"
8
+ This is a normal paragraph\.
9
+ .sp
10
+ .PD 0
11
+ .IP \(bu 4
12
+ A
13
+ .IP \(bu 4
14
+ compact
15
+ .IP \(bu 4
16
+ list
17
+ .IP \(bu 4
18
+ with multiple
19
+ .RS
20
+ .IP \(bu 4
21
+ items and
22
+ .RS
23
+ .IP \(bu 4
24
+ nested
25
+ .RE
26
+ .RE
27
+ .IP \(bu 4
28
+ as well
29
+ .PD
30
+ .RS
31
+ .P
32
+ blockquotes are fine
33
+ .IP 1. 4
34
+ numbered lists
35
+ .IP 2. 4
36
+ work too
37
+ .RS
38
+ .IP 1. 4
39
+ and they
40
+ .IP 2. 4
41
+ can be
42
+ .RS
43
+ .IP 1. 4
44
+ nested
45
+ .RE
46
+ .RE
47
+ .IP 3. 4
48
+ again
49
+ .RE
50
+ .sp
51
+ .RS 4
52
+ .EX
53
+ Some fancy code
54
+ going
55
+ on
56
+ here
57
+ .EE
58
+ .RE
59
+ .TP
60
+ \fB\-o\fP
61
+ .TQ
62
+ \fB\-\-option\fP
63
+ Description lists
64
+ .sp
65
+ are useful as well
66
+ .P
67
+ And compact definition lists:
68
+ .sp
69
+ .PD 0
70
+ .TP
71
+ \fBo\fP
72
+ Option
73
+ .TP
74
+ \fBk\fP
75
+ Key
76
+ .TP
77
+ \fBv\fP
78
+ Value
79
+ .PD
80
+ .TS
81
+ box center ;
82
+ l l l l .
83
+ tables can be centered
84
+ .TE
85
+ .sp
86
+ .TS
87
+ box ;
88
+ lb lb cb rb .
89
+ Default aligned Left aligned Center aligned Right aligned
90
+ =
91
+ .T&
92
+ l l c r .
93
+ First body part Second cell Third cell fourth cell
94
+ Second \fIline\fP foo \fBstrong\fP baz
95
+ Third line \fBquux\fP baz bar
96
+ _
97
+ .T&
98
+ l l c r .
99
+ Second body
100
+ 2nd line
101
+ =
102
+ Footer row one
103
+ Footer row two
104
+ .TE
105
+ .sp
106
+ .P
107
+ Inline formatting like \fIemphasis\fP, \fBstrong\fP and \fBcode span\fP work as ususal\.
108
+ .UR are_well\.html
109
+ Links
110
+ .UE
111
+ work, too! As do
112
+ .br
113
+ line breaks\.
114
+ .P
115
+ Abbreviations like MD can be used but the abbreviation title is ignored\.
116
+ .P
117
+ Math elements work \fB\el = 5\fP inline and in block form:
118
+ .sp
119
+ .RS 4
120
+ .EX
121
+ \elambda_5 = \ealpha + 4
122
+ .EE
123
+ .RE
@@ -0,0 +1,85 @@
1
+ # name(1) - description
2
+ {: data-date="November 2016" data-extra="Some extra data"}
3
+
4
+ ## SYNOPSIS
5
+
6
+ `name` \[`OPTIONS`\] *arguments*...
7
+
8
+ ## DESCRIPTION
9
+
10
+ This is a normal paragraph.
11
+
12
+ * A
13
+ * compact
14
+ * list
15
+ * with multiple
16
+ * items and
17
+ * nested
18
+ * as well
19
+ {:.compact}
20
+
21
+ > blockquotes are fine
22
+ >
23
+ > 1. numbered lists
24
+ >
25
+ > 2. work too
26
+ > 1. and they
27
+ > 2. can be
28
+ > 1. nested
29
+ >
30
+ > 3. again
31
+
32
+ ~~~
33
+ Some fancy code
34
+ going
35
+ on
36
+ here
37
+ ~~~
38
+
39
+ `-o`
40
+ `--option`
41
+ : Description lists
42
+ : are useful as well
43
+
44
+ And compact definition lists:
45
+
46
+ `o`
47
+ : Option
48
+
49
+ `k`
50
+ : Key
51
+
52
+ `v`
53
+ : Value
54
+ {:.compact}
55
+
56
+ | tables | can | be | centered |
57
+ {:.center}
58
+
59
+ |-----------------+------------+-----------------+----------------|
60
+ | Default aligned |Left aligned| Center aligned | Right aligned |
61
+ |-----------------|:-----------|:---------------:|---------------:|
62
+ | First body part |Second cell | Third cell | fourth cell |
63
+ | Second *line* |foo | **strong** | baz |
64
+ | Third line |`quux` | baz | bar |
65
+ |-----------------+------------+-----------------+----------------|
66
+ | Second body | | | |
67
+ | 2nd line | | | |
68
+ |=================+============+=================+================|
69
+ | Footer row one | | | |
70
+ | Footer row two | | | |
71
+ |-----------------+------------+-----------------+----------------|
72
+
73
+
74
+ Inline formatting like *emphasis*, **strong** and `code span` work
75
+ as ususal. [Links](are_well.html) work, too! As do\\
76
+ line breaks.
77
+
78
+ Abbreviations like MD can be used but the abbreviation title is
79
+ ignored.
80
+
81
+ *[MD]: Markdown
82
+
83
+ Math elements work $$\l = 5$$ inline and in block form:
84
+
85
+ $$\lambda_5 = \alpha + 4$$
@@ -0,0 +1,4 @@
1
+ .\" generated by kramdown
2
+ .TH "NAME" "7"
3
+ .SH NAME
4
+ name \- description
@@ -0,0 +1 @@
1
+ # name -- description
@@ -0,0 +1,4 @@
1
+ .\" generated by kramdown
2
+ .TH "NAME" "1" "November 2016" "Something extra"
3
+ .SH NAME
4
+ name \- description
@@ -0,0 +1,2 @@
1
+ # name description
2
+ {: data-section="1" data-date="November 2016" data-extra="Something extra"}
@@ -0,0 +1,4 @@
1
+ .\" generated by kramdown
2
+ .TH "NAME" "1"
3
+ .SH NAME
4
+ name \- description
@@ -0,0 +1 @@
1
+ # name(1) -- description
@@ -0,0 +1,2 @@
1
+ .\" generated by kramdown
2
+ .TH "NAME" "1"
@@ -0,0 +1,2 @@
1
+ .\" generated by kramdown
2
+ .TH "NAME" "7"
@@ -0,0 +1 @@
1
+ # name
@@ -0,0 +1,4 @@
1
+ .\" generated by kramdown
2
+ .SH "NAME"
3
+ works
4
+ .SS "Sub section"
@@ -0,0 +1,11 @@
1
+ ## NAME
2
+
3
+ works
4
+
5
+ ### Sub section
6
+
7
+ #### Ignored
8
+
9
+ ##### Ignored
10
+
11
+ ###### Ignored
@@ -0,0 +1,8 @@
1
+ .\" generated by kramdown
2
+ \&\. at the start of the line
3
+ .P
4
+ line with \efB backslash symbol
5
+ .P
6
+ some \. other \- escaped \' symbols
7
+ .P
8
+ \&\.
@@ -0,0 +1,7 @@
1
+ . at the start of the line
2
+
3
+ line with \fB backslash symbol
4
+
5
+ some . other - escaped \' symbols
6
+
7
+ .
@@ -36,3 +36,5 @@ Mark&rsquo;s name. &ldquo;&hellip;you&rdquo;
36
36
  <p>This: &ldquo;&hellip;some Text&rdquo;</p>
37
37
 
38
38
  <p>This: &ldquo;&hellip; some Text&rdquo;</p>
39
+
40
+ <p>&rdquo;[foo]&rdquo; &ldquo;[foo]&rdquo; d &ldquo;[foo]&rdquo;</p>
@@ -36,3 +36,5 @@ Nam liber tempor
36
36
  This: "...some Text"
37
37
 
38
38
  This: "... some Text"
39
+
40
+ "\[foo]" "\[foo]" d "\[foo]"
@@ -0,0 +1,20 @@
1
+ <p>normal</p>
2
+
3
+ <pre><code class="language-ruby">require 'kramdown'
4
+
5
+ Kramdown::Document.new(text).to_html
6
+ </code></pre>
7
+
8
+ <p>indent with tab</p>
9
+
10
+ <pre><code>```ruby
11
+ require 'kramdown'
12
+
13
+ Kramdown::Document.new(text).to_html
14
+ ```
15
+ </code></pre>
16
+
17
+ <p>indent with 2 spaces</p>
18
+
19
+ <pre><code class="language-js"> console.log("hello");
20
+ </code></pre>