kramdown 1.17.0 → 2.0.0.beta1

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 (196) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +4 -2
  3. data/VERSION +1 -1
  4. data/bin/kramdown +13 -14
  5. data/lib/kramdown.rb +2 -2
  6. data/lib/kramdown/converter.rb +6 -7
  7. data/lib/kramdown/converter/base.rb +18 -29
  8. data/lib/kramdown/converter/hash_ast.rb +4 -4
  9. data/lib/kramdown/converter/html.rb +82 -67
  10. data/lib/kramdown/converter/kramdown.rb +83 -78
  11. data/lib/kramdown/converter/latex.rb +53 -47
  12. data/lib/kramdown/converter/man.rb +22 -25
  13. data/lib/kramdown/converter/math_engine/mathjax.rb +10 -10
  14. data/lib/kramdown/converter/remove_html_tags.rb +2 -2
  15. data/lib/kramdown/converter/syntax_highlighter.rb +2 -2
  16. data/lib/kramdown/converter/syntax_highlighter/minted.rb +2 -2
  17. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +5 -5
  18. data/lib/kramdown/converter/toc.rb +5 -5
  19. data/lib/kramdown/document.rb +9 -11
  20. data/lib/kramdown/element.rb +11 -9
  21. data/lib/kramdown/error.rb +2 -2
  22. data/lib/kramdown/options.rb +258 -384
  23. data/lib/kramdown/parser.rb +2 -3
  24. data/lib/kramdown/parser/base.rb +7 -6
  25. data/lib/kramdown/parser/html.rb +103 -95
  26. data/lib/kramdown/parser/kramdown.rb +32 -36
  27. data/lib/kramdown/parser/kramdown/abbreviation.rb +13 -10
  28. data/lib/kramdown/parser/kramdown/autolink.rb +3 -3
  29. data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
  30. data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
  31. data/lib/kramdown/parser/kramdown/blockquote.rb +4 -5
  32. data/lib/kramdown/parser/kramdown/codeblock.rb +4 -5
  33. data/lib/kramdown/parser/kramdown/codespan.rb +5 -5
  34. data/lib/kramdown/parser/kramdown/emphasis.rb +6 -6
  35. data/lib/kramdown/parser/kramdown/eob.rb +2 -2
  36. data/lib/kramdown/parser/kramdown/escaped_chars.rb +2 -2
  37. data/lib/kramdown/parser/kramdown/extensions.rb +31 -26
  38. data/lib/kramdown/parser/kramdown/footnote.rb +7 -6
  39. data/lib/kramdown/parser/kramdown/header.rb +6 -6
  40. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +3 -3
  41. data/lib/kramdown/parser/kramdown/html.rb +31 -26
  42. data/lib/kramdown/parser/kramdown/html_entity.rb +6 -5
  43. data/lib/kramdown/parser/kramdown/line_break.rb +3 -3
  44. data/lib/kramdown/parser/kramdown/link.rb +13 -11
  45. data/lib/kramdown/parser/kramdown/list.rb +38 -40
  46. data/lib/kramdown/parser/kramdown/math.rb +4 -5
  47. data/lib/kramdown/parser/kramdown/paragraph.rb +5 -5
  48. data/lib/kramdown/parser/kramdown/smart_quotes.rb +23 -23
  49. data/lib/kramdown/parser/kramdown/table.rb +18 -17
  50. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +8 -8
  51. data/lib/kramdown/parser/markdown.rb +9 -8
  52. data/lib/kramdown/utils.rb +5 -6
  53. data/lib/kramdown/utils/configurable.rb +7 -6
  54. data/lib/kramdown/utils/entities.rb +286 -289
  55. data/lib/kramdown/utils/html.rb +10 -12
  56. data/lib/kramdown/utils/lru_cache.rb +3 -2
  57. data/lib/kramdown/utils/string_scanner.rb +2 -3
  58. data/lib/kramdown/utils/unidecoder.rb +8 -6
  59. data/lib/kramdown/version.rb +3 -3
  60. data/man/man1/kramdown.1 +3 -107
  61. data/test/run_tests.rb +6 -6
  62. data/test/test_files.rb +122 -298
  63. data/test/test_location.rb +8 -30
  64. data/test/test_string_scanner_kramdown.rb +6 -9
  65. data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -6
  66. data/test/testcases/block/06_codeblock/highlighting.html +5 -6
  67. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +1 -1
  68. data/test/testcases/block/07_horizontal_rule/error.html +2 -2
  69. data/test/testcases/block/09_html/html5_attributes.html +2 -0
  70. data/test/testcases/block/09_html/html5_attributes.text +2 -0
  71. data/test/testcases/block/09_html/html_to_native/typography.html +1 -1
  72. data/test/testcases/block/09_html/simple.html +1 -1
  73. data/test/testcases/block/12_extension/options3.html +7 -6
  74. data/test/testcases/block/12_extension/options3.text +2 -2
  75. data/test/testcases/span/01_link/inline.html +1 -1
  76. data/test/testcases/span/01_link/reference.html +3 -3
  77. data/test/testcases/span/03_codespan/highlighting.html +1 -1
  78. data/test/testcases/span/text_substitutions/entities_as_char.html +1 -1
  79. metadata +5 -234
  80. data/Rakefile +0 -341
  81. data/benchmark/benchmark.rb +0 -43
  82. data/benchmark/benchmark.sh +0 -74
  83. data/benchmark/generate_data.rb +0 -119
  84. data/benchmark/mdbasics.text +0 -306
  85. data/benchmark/mdsyntax.text +0 -888
  86. data/benchmark/testing.sh +0 -12
  87. data/benchmark/timing.sh +0 -10
  88. data/doc/_design.scss +0 -441
  89. data/doc/bg.png +0 -0
  90. data/doc/default.scss +0 -217
  91. data/doc/default.template +0 -62
  92. data/doc/documentation.page +0 -84
  93. data/doc/documentation.template +0 -36
  94. data/doc/index.page +0 -113
  95. data/doc/installation.page +0 -88
  96. data/doc/links.markdown +0 -6
  97. data/doc/metainfo +0 -13
  98. data/doc/news.feed +0 -9
  99. data/doc/news.page +0 -29
  100. data/doc/options.page +0 -49
  101. data/doc/quickref.page +0 -603
  102. data/doc/sidebar.template +0 -22
  103. data/doc/sitemap.sitemap +0 -5
  104. data/doc/syntax.page +0 -1799
  105. data/doc/tests.page +0 -104
  106. data/doc/virtual +0 -14
  107. data/lib/kramdown/converter/math_engine/itex2mml.rb +0 -39
  108. data/lib/kramdown/converter/math_engine/katex.rb +0 -35
  109. data/lib/kramdown/converter/math_engine/mathjaxnode.rb +0 -56
  110. data/lib/kramdown/converter/math_engine/ritex.rb +0 -38
  111. data/lib/kramdown/converter/math_engine/sskatex.rb +0 -97
  112. data/lib/kramdown/converter/pdf.rb +0 -625
  113. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +0 -81
  114. data/lib/kramdown/parser/gfm.rb +0 -188
  115. data/lib/kramdown/utils/ordered_hash.rb +0 -18
  116. data/setup.rb +0 -1585
  117. data/test/testcases/block/07_horizontal_rule/error.html.19 +0 -7
  118. data/test/testcases/block/09_html/html_to_native/typography.html.19 +0 -1
  119. data/test/testcases/block/09_html/simple.html.19 +0 -60
  120. data/test/testcases/block/15_math/itex2mml.html +0 -1
  121. data/test/testcases/block/15_math/itex2mml.options +0 -1
  122. data/test/testcases/block/15_math/itex2mml.text +0 -1
  123. data/test/testcases/block/15_math/katex.html.19 +0 -2
  124. data/test/testcases/block/15_math/katex.options +0 -1
  125. data/test/testcases/block/15_math/katex.text +0 -2
  126. data/test/testcases/block/15_math/mathjaxnode.html.19 +0 -27
  127. data/test/testcases/block/15_math/mathjaxnode.options +0 -1
  128. data/test/testcases/block/15_math/mathjaxnode.text +0 -1
  129. data/test/testcases/block/15_math/mathjaxnode_notexhints.html.19 +0 -23
  130. data/test/testcases/block/15_math/mathjaxnode_notexhints.options +0 -3
  131. data/test/testcases/block/15_math/mathjaxnode_notexhints.text +0 -1
  132. data/test/testcases/block/15_math/mathjaxnode_semantics.html.19 +0 -32
  133. data/test/testcases/block/15_math/mathjaxnode_semantics.options +0 -3
  134. data/test/testcases/block/15_math/mathjaxnode_semantics.text +0 -1
  135. data/test/testcases/block/15_math/ritex.html +0 -1
  136. data/test/testcases/block/15_math/ritex.options +0 -1
  137. data/test/testcases/block/15_math/ritex.text +0 -1
  138. data/test/testcases/block/15_math/sskatex.html.19 +0 -2
  139. data/test/testcases/block/15_math/sskatex.options +0 -1
  140. data/test/testcases/block/15_math/sskatex.text +0 -2
  141. data/test/testcases/span/01_link/inline.html.19 +0 -46
  142. data/test/testcases/span/01_link/reference.html.19 +0 -37
  143. data/test/testcases/span/math/itex2mml.html +0 -1
  144. data/test/testcases/span/math/itex2mml.options +0 -1
  145. data/test/testcases/span/math/itex2mml.text +0 -1
  146. data/test/testcases/span/math/katex.html.19 +0 -1
  147. data/test/testcases/span/math/katex.options +0 -1
  148. data/test/testcases/span/math/katex.text +0 -1
  149. data/test/testcases/span/math/mathjaxnode.html.19 +0 -27
  150. data/test/testcases/span/math/mathjaxnode.options +0 -1
  151. data/test/testcases/span/math/mathjaxnode.text +0 -1
  152. data/test/testcases/span/math/ritex.html +0 -1
  153. data/test/testcases/span/math/ritex.options +0 -1
  154. data/test/testcases/span/math/ritex.text +0 -1
  155. data/test/testcases/span/math/sskatex.html.19 +0 -1
  156. data/test/testcases/span/math/sskatex.options +0 -1
  157. data/test/testcases/span/math/sskatex.text +0 -1
  158. data/test/testcases/span/text_substitutions/entities_as_char.html.19 +0 -1
  159. data/test/testcases_gfm/atx_header.html +0 -3
  160. data/test/testcases_gfm/atx_header.text +0 -3
  161. data/test/testcases_gfm/backticks_disable_highlighting.html +0 -2
  162. data/test/testcases_gfm/backticks_disable_highlighting.options +0 -1
  163. data/test/testcases_gfm/backticks_disable_highlighting.text +0 -3
  164. data/test/testcases_gfm/backticks_syntax.html +0 -20
  165. data/test/testcases_gfm/backticks_syntax.text +0 -19
  166. data/test/testcases_gfm/codeblock_fenced.html +0 -20
  167. data/test/testcases_gfm/codeblock_fenced.options +0 -1
  168. data/test/testcases_gfm/codeblock_fenced.text +0 -21
  169. data/test/testcases_gfm/hard_line_breaks.html +0 -3
  170. data/test/testcases_gfm/hard_line_breaks.text +0 -3
  171. data/test/testcases_gfm/hard_line_breaks_off.html +0 -2
  172. data/test/testcases_gfm/hard_line_breaks_off.options +0 -1
  173. data/test/testcases_gfm/hard_line_breaks_off.text +0 -2
  174. data/test/testcases_gfm/header_ids.html +0 -27
  175. data/test/testcases_gfm/header_ids.html.19 +0 -27
  176. data/test/testcases_gfm/header_ids.options +0 -1
  177. data/test/testcases_gfm/header_ids.text +0 -27
  178. data/test/testcases_gfm/header_ids_with_prefix.html +0 -3
  179. data/test/testcases_gfm/header_ids_with_prefix.options +0 -2
  180. data/test/testcases_gfm/header_ids_with_prefix.text +0 -3
  181. data/test/testcases_gfm/no_typographic.html +0 -3
  182. data/test/testcases_gfm/no_typographic.html.19 +0 -3
  183. data/test/testcases_gfm/no_typographic.options +0 -1
  184. data/test/testcases_gfm/no_typographic.text +0 -3
  185. data/test/testcases_gfm/paragraph_end-disabled.html +0 -31
  186. data/test/testcases_gfm/paragraph_end-disabled.options +0 -1
  187. data/test/testcases_gfm/paragraph_end-disabled.text +0 -27
  188. data/test/testcases_gfm/paragraph_end.html +0 -38
  189. data/test/testcases_gfm/paragraph_end.text +0 -27
  190. data/test/testcases_gfm/strikethrough.html +0 -27
  191. data/test/testcases_gfm/strikethrough.html.19 +0 -27
  192. data/test/testcases_gfm/strikethrough.text +0 -27
  193. data/test/testcases_gfm/task_list.html +0 -40
  194. data/test/testcases_gfm/task_list.text +0 -26
  195. data/test/testcases_gfm/two_para_hard_line_breaks.html +0 -4
  196. data/test/testcases_gfm/two_para_hard_line_breaks.text +0 -4
@@ -1,7 +1,7 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -29,11 +29,11 @@ module Kramdown
29
29
 
30
30
  if entity_output == :as_char &&
31
31
  (c = e.char.encode(@root.options[:encoding]) rescue nil) &&
32
- ((c = e.char) == '"' || !ESCAPE_MAP.has_key?(c))
32
+ ((c = e.char) == '"' || !ESCAPE_MAP.key?(c))
33
33
  c
34
34
  elsif (entity_output == :as_input || entity_output == :as_char) && original
35
35
  original
36
- elsif (entity_output == :symbolic || ESCAPE_MAP.has_key?(e.char)) && !e.name.nil?
36
+ elsif (entity_output == :symbolic || ESCAPE_MAP.key?(e.char)) && !e.name.nil?
37
37
  "&#{e.name};"
38
38
  else # default to :numeric
39
39
  "&##{e.code_point};"
@@ -42,7 +42,9 @@ module Kramdown
42
42
 
43
43
  # Return the HTML representation of the attributes +attr+.
44
44
  def html_attributes(attr)
45
- attr.map {|k,v| v.nil? || (k == 'id' && v.strip.empty?) ? '' : " #{k}=\"#{escape_html(v.to_s, :attribute)}\"" }.join('')
45
+ attr.map do |k, v|
46
+ v.nil? || (k == 'id' && v.strip.empty?) ? '' : " #{k}=\"#{escape_html(v.to_s, :attribute)}\""
47
+ end.join('')
46
48
  end
47
49
 
48
50
  # :stopdoc:
@@ -50,16 +52,12 @@ module Kramdown
50
52
  '<' => '&lt;',
51
53
  '>' => '&gt;',
52
54
  '&' => '&amp;',
53
- '"' => '&quot;'
55
+ '"' => '&quot;',
54
56
  }
55
57
  ESCAPE_ALL_RE = /<|>|&/
56
58
  ESCAPE_TEXT_RE = Regexp.union(REXML::Parsers::BaseParser::REFERENCE_RE, /<|>|&/)
57
59
  ESCAPE_ATTRIBUTE_RE = Regexp.union(REXML::Parsers::BaseParser::REFERENCE_RE, /<|>|&|"/)
58
- ESCAPE_RE_FROM_TYPE = {
59
- :all => ESCAPE_ALL_RE,
60
- :text => ESCAPE_TEXT_RE,
61
- :attribute => ESCAPE_ATTRIBUTE_RE
62
- }
60
+ ESCAPE_RE_FROM_TYPE = {all: ESCAPE_ALL_RE, text: ESCAPE_TEXT_RE, attribute: ESCAPE_ATTRIBUTE_RE}
63
61
  # :startdoc:
64
62
 
65
63
  # Escape the special HTML characters in the string +str+. The parameter +type+ specifies what
@@ -67,7 +65,7 @@ module Kramdown
67
65
  # entities, :text - all special HTML characters except the quotation mark but no entities and
68
66
  # :attribute - all special HTML characters including the quotation mark but no entities.
69
67
  def escape_html(str, type = :all)
70
- str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m}
68
+ str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m }
71
69
  end
72
70
 
73
71
  end
@@ -1,10 +1,11 @@
1
- # -*- encoding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2014-2017 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
8
+ #
8
9
 
9
10
  module Kramdown
10
11
  module Utils
@@ -1,13 +1,12 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
8
8
  #
9
9
 
10
-
11
10
  require 'strscan'
12
11
 
13
12
  module Kramdown
@@ -1,7 +1,7 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -15,8 +15,10 @@ module Kramdown
15
15
  # Provides the ability to tranliterate Unicode strings into plain ASCII ones.
16
16
  module Unidecoder
17
17
 
18
- gem 'stringex' if defined?(Gem)
19
- path = $:.find {|dir| File.directory?(File.join(File.expand_path(dir), "stringex", "unidecoder_data"))}
18
+ gem 'stringex'
19
+ path = $:.find do |dir|
20
+ File.directory?(File.join(File.expand_path(dir), "stringex", "unidecoder_data"))
21
+ end
20
22
 
21
23
  if !path
22
24
  def self.decode(string)
@@ -33,8 +35,8 @@ module Kramdown
33
35
  string.gsub(/[^\x00-\x7f]/u) do |codepoint|
34
36
  begin
35
37
  unpacked = codepoint.unpack("U")[0]
36
- CODEPOINTS["x%02x" % (unpacked >> 8)][unpacked & 255]
37
- rescue
38
+ CODEPOINTS[sprintf("x%02x", unpacked >> 8)][unpacked & 255]
39
+ rescue StandardError
38
40
  "?"
39
41
  end
40
42
  end
@@ -1,7 +1,7 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -10,6 +10,6 @@
10
10
  module Kramdown
11
11
 
12
12
  # The kramdown version.
13
- VERSION = '1.17.0'
13
+ VERSION = '2.0.0.beta1'
14
14
 
15
15
  end
@@ -15,10 +15,10 @@ Default values for this second set can be set using YAML via the configuration f
15
15
  .SH "CLI\-ONLY OPTIONS"
16
16
  .TP
17
17
  \fB\-i\fP \fIFORMAT\fP, \fB\-\-input\fP \fIFORMAT\fP
18
- Specify the input format\. Available input formats: \fIkramdown\fP (this is the default), \fImarkdown\fP, \fIGFM\fP or \fIhtml\fP\&\.
18
+ Specify the input format\. Available input formats: \fIkramdown\fP (this is the default), \fImarkdown\fP, or \fIhtml\fP\&\. The input format \fIGFM\fP is available through the \fBkramdown\-parser\-gfm\fP gem\.
19
19
  .TP
20
20
  \fB\-o\fP \fIFORMAT\fP, \fB\-\-output\fP \fIFORMAT\fP
21
- Specify one or more output formats separated by commas: \fIhtml\fP (default), \fIkramdown\fP, \fIlatex\fP, \fIpdf\fP, \fIman\fP or \fIremove_html_tags\fP\&\.
21
+ Specify one or more output formats separated by commas: \fIhtml\fP (default), \fIkramdown\fP, \fIlatex\fP, \fIman\fP or \fIremove_html_tags\fP\&\. The converter \fIpdf\fP is available through the \fBkramdown\-converter\-pdf\fP gem\.
22
22
  .TP
23
23
  \fB\-\-no\-config\-file\fP
24
24
  Do not read any configuration file\. Default behavior is to check for a configuration file and read it if it exists\.
@@ -62,74 +62,6 @@ If this option is \fBtrue\fP, ID values for all headers are automatically genera
62
62
  Default: true Used by: HTML/Latex converter
63
63
  .RE
64
64
  .TP
65
- \fB\-\-coderay\-bold\-every\fP \fIARG\fP
66
- Defines how often a line number should be made bold
67
- .RS
68
- .P
69
- Can either be an integer or false (to turn off bold line numbers completely)\.
70
- .P
71
- Default: 10 Used by: HTML converter
72
- .RE
73
- .TP
74
- \fB\-\-coderay\-css\fP \fIARG\fP
75
- Defines how the highlighted code gets styled
76
- .RS
77
- .P
78
- Possible values are :class (CSS classes are applied to the code elements, one must supply the needed CSS file) or :style (default CSS styles are directly applied to the code elements)\.
79
- .P
80
- Default: style Used by: HTML converter
81
- .RE
82
- .TP
83
- \fB\-\-coderay\-default\-lang\fP \fIARG\fP
84
- Sets the default language for highlighting code blocks
85
- .RS
86
- .P
87
- If no language is set for a code block, the default language is used instead\. The value has to be one of the languages supported by coderay or nil if no default language should be used\.
88
- .P
89
- Default: nil Used by: HTML converter
90
- .RE
91
- .TP
92
- \fB\-\-coderay\-line\-number\-start\fP \fIARG\fP
93
- The start value for the line numbers
94
- .RS
95
- .P
96
- Default: 1 Used by: HTML converter
97
- .RE
98
- .TP
99
- \fB\-\-coderay\-line\-numbers\fP \fIARG\fP
100
- Defines how and if line numbers should be shown
101
- .RS
102
- .P
103
- The possible values are :table, :inline or nil\. If this option is nil, no line numbers are shown\.
104
- .P
105
- Default: :inline Used by: HTML converter
106
- .RE
107
- .TP
108
- \fB\-\-coderay\-tab\-width\fP \fIARG\fP
109
- The tab width used in highlighted code
110
- .RS
111
- .P
112
- Used by: HTML converter
113
- .RE
114
- .TP
115
- \fB\-\-coderay\-wrap\fP \fIARG\fP
116
- Defines how the highlighted code should be wrapped
117
- .RS
118
- .P
119
- The possible values are :span, :div or nil\.
120
- .P
121
- Default: :div Used by: HTML converter
122
- .RE
123
- .TP
124
- \fB\-\-[no\-]enable\-coderay\fP
125
- Use coderay for syntax highlighting
126
- .RS
127
- .P
128
- If this option is \fBtrue\fP, coderay is used by the HTML converter for syntax highlighting the content of code spans and code blocks\.
129
- .P
130
- Default: true Used by: HTML converter
131
- .RE
132
- .TP
133
65
  \fB\-\-entity\-output\fP \fIARG\fP
134
66
  Defines how entities are output
135
67
  .RS
@@ -170,42 +102,6 @@ This option can be used to specify the number that is used for the first footnot
170
102
  Default: 1 Used by: HTML converter
171
103
  .RE
172
104
  .TP
173
- \fB\-\-gfm\-quirks\fP \fIARG\fP
174
- Enables a set of GFM specific quirks
175
- .RS
176
- .P
177
- The way how GFM is transformed on Github often differs from the way kramdown does things\. Many of these differences are negligible but others are not\.
178
- .P
179
- This option allows one to enable/disable certain GFM quirks, i\.e\. ways in which GFM parsing differs from kramdown parsing\.
180
- .P
181
- The value has to be a list of quirk names that should be enabled, separated by commas\. Possible names are:
182
- .IP \(bu 4
183
- paragraph_end
184
- .RS
185
- .P
186
- Disables the kramdown restriction that at least one blank line has to be used after a paragraph before a new block element can be started\.
187
- .P
188
- Note that if this quirk is used, lazy line wrapping does not fully work anymore!
189
- .RE
190
- .IP \(bu 4
191
- no_auto_typographic
192
- .RS
193
- .P
194
- Disables automatic conversion of some characters into their corresponding typographic symbols (like \fB\-\-\fP to em\-dash etc)\. This helps to achieve results closer to what GitHub Flavored Markdown produces\.
195
- .RE
196
- .P
197
- Default: paragraph_end Used by: GFM parser
198
- .RE
199
- .TP
200
- \fB\-\-[no\-]hard\-wrap\fP
201
- Interprets line breaks literally
202
- .RS
203
- .P
204
- Insert HTML \fB<br />\fP tags inside paragraphs where the original Markdown document had newlines (by default, Markdown ignores these newlines)\.
205
- .P
206
- Default: true Used by: GFM parser
207
- .RE
208
- .TP
209
105
  \fB\-\-header\-offset\fP \fIARG\fP
210
106
  Sets the output offset for headers
211
107
  .RS
@@ -328,7 +224,7 @@ Specifies the syntax highlighter that should be used for highlighting code block
328
224
  .P
329
225
  Options for the syntax highlighter can be set with the syntax_highlighter_opts configuration option\.
330
226
  .P
331
- Default: coderay Used by: HTML/Latex converter
227
+ Default: rouge Used by: HTML/Latex converter
332
228
  .RE
333
229
  .TP
334
230
  \fB\-\-syntax\-highlighter\-opts\fP \fIARG\fP
@@ -1,7 +1,7 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -22,7 +22,7 @@ arg = if File.directory?(arg)
22
22
  arg + '.text'
23
23
  end
24
24
 
25
- width = ((size = %x{stty size 2>/dev/null}).length > 0 ? size.split.last.to_i : 72) rescue 72
25
+ width = ((size = `stty size 2>/dev/null`).length > 0 ? size.split.last.to_i : 72) rescue 72
26
26
  width -= 8
27
27
  fwidth = 0
28
28
  Dir[arg].each {|f| fwidth = [fwidth, f.length + 10].max }.each do |file|
@@ -31,13 +31,13 @@ Dir[arg].each {|f| fwidth = [fwidth, f.length + 10].max }.each do |file|
31
31
 
32
32
  html_file = file.sub('.text', '.html')
33
33
  opts_file = file.sub('.text', '.options')
34
- opts_file = File.join(File.dirname(file), 'options') if !File.exist?(opts_file)
35
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
34
+ opts_file = File.join(File.dirname(file), 'options') unless File.exist?(opts_file)
35
+ options = File.exist?(opts_file) ? YAML.safe_load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
36
36
  doc = Kramdown::Document.new(File.read(file), options)
37
37
  begin
38
38
  assert_equal(File.read(html_file), doc.to_html)
39
39
  puts 'PASSED'
40
- rescue Exception => e
40
+ rescue StandardError
41
41
  puts ' FAILED'
42
42
  puts $!.message if $VERBOSE
43
43
  puts $!.backtrace if $DEBUG
@@ -1,7 +1,7 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -21,6 +21,7 @@ begin
21
21
 
22
22
  # custom formatter for tests
23
23
  class RougeHTMLFormatters < Kramdown::Converter::SyntaxHighlighter::Rouge.formatter_class
24
+
24
25
  tag 'rouge_html_formatters'
25
26
 
26
27
  def stream(tokens, &b)
@@ -28,58 +29,28 @@ begin
28
29
  super
29
30
  yield %(</div>)
30
31
  end
32
+
31
33
  end
32
34
  rescue LoadError, SyntaxError, NameError
33
35
  end
34
36
 
35
- Encoding.default_external = 'utf-8' if RUBY_VERSION >= '1.9'
37
+ Encoding.default_external = 'utf-8'
36
38
 
37
39
  class TestFiles < Minitest::Test
38
40
 
39
- MATHJAX_NODE_AVAILABLE = begin
40
- require 'kramdown/converter/math_engine/mathjaxnode'
41
- Kramdown::Converter::MathEngine::MathjaxNode::AVAILABLE or
42
- warn("Skipping MathjaxNode tests as MathjaxNode is not available")
43
- end
44
-
45
- SSKATEX_AVAILABLE = begin
46
- / class="katex"/ === Kramdown::Document.
47
- new('$$a$$', {:math_engine => :sskatex}).to_html or
48
- warn("Skipping SsKaTeX tests as SsKaTeX is not available.")
49
- rescue
50
- warn("Skipping SsKaTeX tests as default SsKaTeX config does not work.")
51
- end or warn("Run \"rake dev:test_sskatex_deps\" to see why.")
52
-
53
- KATEX_AVAILABLE = RUBY_VERSION >= '2.3'
54
-
55
- EXCLUDE_KD_FILES = [('test/testcases/block/04_header/with_auto_ids.text' if RUBY_VERSION <= '1.8.6'), # bc of dep stringex not working
56
- ('test/testcases/span/03_codespan/rouge/' if RUBY_VERSION < '2.0'), #bc of rouge
57
- ('test/testcases/block/06_codeblock/rouge/' if RUBY_VERSION < '2.0'), #bc of rouge
58
- ('test/testcases/block/15_math/itex2mml.text' if RUBY_PLATFORM == 'java'), # bc of itextomml
59
- ('test/testcases/span/math/itex2mml.text' if RUBY_PLATFORM == 'java'), # bc of itextomml
60
- ('test/testcases/block/15_math/mathjaxnode.text' unless MATHJAX_NODE_AVAILABLE),
61
- ('test/testcases/block/15_math/mathjaxnode_notexhints.text' unless MATHJAX_NODE_AVAILABLE),
62
- ('test/testcases/block/15_math/mathjaxnode_semantics.text' unless MATHJAX_NODE_AVAILABLE),
63
- ('test/testcases/span/math/mathjaxnode.text' unless MATHJAX_NODE_AVAILABLE),
64
- ('test/testcases/block/15_math/sskatex.text' unless SSKATEX_AVAILABLE),
65
- ('test/testcases/span/math/sskatex.text' unless SSKATEX_AVAILABLE),
66
- ('test/testcases/block/15_math/katex.text' unless KATEX_AVAILABLE),
67
- ('test/testcases/span/math/katex.text' unless KATEX_AVAILABLE),
68
- ].compact
41
+ EXCLUDE_KD_FILES = [].compact
69
42
 
70
43
  # Generate test methods for kramdown-to-xxx conversion
71
44
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
72
- next if EXCLUDE_KD_FILES.any? {|f| text_file =~ /#{f}/}
45
+ next if EXCLUDE_KD_FILES.any? {|f| text_file =~ /#{f}/ }
73
46
  basename = text_file.sub(/\.text$/, '')
74
47
  opts_file = text_file.sub(/\.text$/, '.options')
75
48
  (Dir[basename + ".*"] - [text_file, opts_file]).each do |output_file|
76
- next if (RUBY_VERSION >= '1.9' && File.exist?(output_file + '.19')) ||
77
- (RUBY_VERSION < '1.9' && output_file =~ /\.19$/)
78
- output_format = File.extname(output_file.sub(/\.19$/, ''))[1..-1]
79
- next if !Kramdown::Converter.const_defined?(output_format[0..0].upcase + output_format[1..-1])
49
+ output_format = File.extname(output_file)[1..-1]
50
+ next unless Kramdown::Converter.const_defined?(output_format[0..0].upcase + output_format[1..-1])
80
51
  define_method('test_' + text_file.tr('.', '_') + "_to_#{output_format}") do
81
- opts_file = File.join(File.dirname(text_file), 'options') if !File.exist?(opts_file)
82
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
52
+ opts_file = File.join(File.dirname(text_file), 'options') unless File.exist?(opts_file)
53
+ options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
83
54
  doc = Kramdown::Document.new(File.read(text_file), options)
84
55
  assert_equal(File.read(output_file), doc.send("to_#{output_format}"))
85
56
  end
@@ -91,54 +62,43 @@ class TestFiles < Minitest::Test
91
62
  if $?.exitstatus != 0
92
63
  warn("Skipping html-to-{html,kramdown} tests because tidy executable is missing")
93
64
  else
94
- EXCLUDE_HTML_FILES = ['test/testcases/block/06_codeblock/whitespace.html', # bc of span inside pre
95
- 'test/testcases/block/09_html/simple.html', # bc of xml elements
96
- 'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element
97
- 'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option
98
- 'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option
99
- 'test/testcases/block/06_codeblock/rouge/simple.html', # bc of double surrounding <div>
100
- 'test/testcases/block/06_codeblock/rouge/multiple.html', # bc of double surrounding <div>
101
- ('test/testcases/span/03_codespan/rouge/simple.html' if RUBY_VERSION < '2.0'),
102
- ('test/testcases/span/03_codespan/rouge/disabled.html' if RUBY_VERSION < '2.0'),
103
- 'test/testcases/block/14_table/empty_tag_in_cell.html', # bc of tidy
104
- 'test/testcases/block/15_math/ritex.html', # bc of tidy
105
- 'test/testcases/span/math/ritex.html', # bc of tidy
106
- 'test/testcases/block/15_math/itex2mml.html', # bc of tidy
107
- 'test/testcases/span/math/itex2mml.html', # bc of tidy
108
- 'test/testcases/block/15_math/mathjaxnode.html', # bc of tidy
109
- 'test/testcases/block/15_math/mathjaxnode_notexhints.html', # bc of tidy
110
- 'test/testcases/block/15_math/mathjaxnode_semantics.html', # bc of tidy
111
- 'test/testcases/span/math/mathjaxnode.html', # bc of tidy
112
- 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
113
- 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
114
- 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview
115
- 'test/testcases/span/math/sskatex.html', # bc of tidy
116
- 'test/testcases/block/15_math/sskatex.html', # bc of tidy
117
- 'test/testcases/span/math/katex.html', # bc of tidy
118
- 'test/testcases/block/15_math/katex.html', # bc of tidy
119
- 'test/testcases/span/05_html/mark_element.html', # bc of tidy
120
- 'test/testcases/block/09_html/xml.html', # bc of tidy
121
- 'test/testcases/span/05_html/xml.html', # bc of tidy
122
- ].compact
123
- EXCLUDE_HTML_TEXT_FILES = ['test/testcases/block/09_html/parse_as_span.htmlinput',
124
- 'test/testcases/block/09_html/parse_as_raw.htmlinput',
125
- ].compact
126
- Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,html.19,htmlinput,htmlinput.19}'].each do |html_file|
127
- next if EXCLUDE_HTML_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
128
- next if (RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')) ||
129
- (RUBY_VERSION < '1.9' && html_file =~ /\.19$/)
65
+ EXCLUDE_HTML_FILES = [
66
+ 'test/testcases/block/06_codeblock/whitespace.html', # bc of span inside pre
67
+ 'test/testcases/block/09_html/simple.html', # bc of xml elements
68
+ 'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element
69
+ 'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option
70
+ 'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option
71
+ 'test/testcases/block/06_codeblock/rouge/simple.html', # bc of double surrounding <div>
72
+ 'test/testcases/block/06_codeblock/rouge/multiple.html', # bc of double surrounding <div>
73
+ 'test/testcases/block/06_codeblock/highlighting.html', # bc of span elements inside code element
74
+ 'test/testcases/block/06_codeblock/highlighting-opts.html', # bc of span elements inside code element
75
+ 'test/testcases/block/12_extension/options3.html', # bc of rouge
76
+ 'test/testcases/block/14_table/empty_tag_in_cell.html', # bc of tidy
77
+ 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
78
+ 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
79
+ 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview
80
+ 'test/testcases/span/05_html/mark_element.html', # bc of tidy
81
+ 'test/testcases/block/09_html/xml.html', # bc of tidy
82
+ 'test/testcases/span/05_html/xml.html', # bc of tidy
83
+ ].compact
84
+ EXCLUDE_HTML_TEXT_FILES = [
85
+ 'test/testcases/block/09_html/parse_as_span.htmlinput',
86
+ 'test/testcases/block/09_html/parse_as_raw.htmlinput',
87
+ ].compact
88
+ Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,htmlinput}'].each do |html_file|
89
+ next if EXCLUDE_HTML_FILES.any? {|f| html_file =~ /#{f}/ }
130
90
 
131
91
  out_files = []
132
- out_files << [(html_file =~ /\.htmlinput(\.19)?$/ ? html_file.sub(/input(\.19)?$/, '') : html_file), :to_html]
133
- if html_file =~ /\.htmlinput(\.19)?$/ && !EXCLUDE_HTML_TEXT_FILES.any? {|f| html_file =~ /#{f}/}
134
- out_files << [html_file.sub(/htmlinput(\.19)?$/, 'text'), :to_kramdown]
92
+ out_files << [(html_file =~ /\.htmlinput$/ ? html_file.sub(/input$/, '') : html_file), :to_html]
93
+ if html_file =~ /\.htmlinput$/ && EXCLUDE_HTML_TEXT_FILES.none? {|f| html_file =~ /#{f}/ }
94
+ out_files << [html_file.sub(/htmlinput$/, 'text'), :to_kramdown]
135
95
  end
136
- out_files.select {|f, _| File.exist?(f)}.each do |out_file, out_method|
96
+ out_files.select {|f, _| File.exist?(f) }.each do |out_file, out_method|
137
97
  define_method('test_' + html_file.tr('.', '_') + "_to_#{File.extname(out_file)}") do
138
- opts_file = html_file.sub(/\.html(input)?(\.19)?$/, '.options')
139
- opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file)
140
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
141
- doc = Kramdown::Document.new(File.read(html_file), options.merge(:input => 'html'))
98
+ opts_file = html_file.sub(/\.html(input)?$/, '.options')
99
+ opts_file = File.join(File.dirname(html_file), 'options') unless File.exist?(opts_file)
100
+ options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
101
+ doc = Kramdown::Document.new(File.read(html_file), options.merge(input: 'html'))
142
102
  if out_method == :to_html
143
103
  assert_equal(tidy_output(File.read(out_file)), tidy_output(doc.send(out_method)))
144
104
  else
@@ -167,19 +127,19 @@ class TestFiles < Minitest::Test
167
127
  if $?.exitstatus != 0
168
128
  warn("Skipping latex compilation tests because latex executable is missing")
169
129
  else
170
- EXCLUDE_LATEX_FILES = ['test/testcases/span/01_link/image_in_a.text', # bc of image link
171
- 'test/testcases/span/01_link/imagelinks.text', # bc of image links
172
- 'test/testcases/span/01_link/empty_title.text',
173
- 'test/testcases/span/04_footnote/markers.text', # bc of footnote in header
174
- 'test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text',
175
- 'test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text',
176
- ].compact
130
+ EXCLUDE_LATEX_FILES = [
131
+ 'test/testcases/span/01_link/image_in_a.text', # bc of image link
132
+ 'test/testcases/span/01_link/imagelinks.text', # bc of image links
133
+ 'test/testcases/span/01_link/empty_title.text',
134
+ 'test/testcases/span/04_footnote/markers.text', # bc of footnote in header
135
+ 'test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text',
136
+ 'test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text',
137
+ ].compact
177
138
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
178
- next if EXCLUDE_LATEX_FILES.any? {|f| text_file =~ /#{f}$/}
139
+ next if EXCLUDE_LATEX_FILES.any? {|f| text_file =~ /#{f}$/ }
179
140
  define_method('test_' + text_file.tr('.', '_') + "_to_latex_compilation") do
180
- latex = Kramdown::Document.new(File.read(text_file),
181
- :auto_ids => false, :footnote_nr => 1,
182
- :template => 'document').to_latex
141
+ latex = Kramdown::Document.new(File.read(text_file), auto_ids: false, footnote_nr: 1,
142
+ template: 'document').to_latex
183
143
  Dir.mktmpdir do |tmpdir|
184
144
  result = IO.popen("latex -output-directory='#{tmpdir}' 2>/dev/null", 'r+') do |io|
185
145
  io.write(latex)
@@ -197,50 +157,35 @@ class TestFiles < Minitest::Test
197
157
  if $?.exitstatus != 0
198
158
  warn("Skipping text->kramdown->html tests because tidy executable is missing")
199
159
  else
200
- EXCLUDE_TEXT_FILES = ['test/testcases/span/05_html/markdown_attr.text', # bc of markdown attr
201
- 'test/testcases/block/09_html/markdown_attr.text', # bc of markdown attr
202
- 'test/testcases/span/extension/options.text', # bc of parse_span_html option
203
- 'test/testcases/block/12_extension/options.text', # bc of options option
204
- 'test/testcases/block/12_extension/options3.text', # bc of options option
205
- 'test/testcases/block/09_html/content_model/tables.text', # bc of parse_block_html option
206
- 'test/testcases/block/09_html/html_to_native/header.text', # bc of auto_ids option that interferes
207
- 'test/testcases/block/09_html/html_to_native/table_simple.text', # bc of tr style attr getting removed
208
- 'test/testcases/block/09_html/simple.text', # bc of webgen:block elements
209
- 'test/testcases/block/11_ial/simple.text', # bc of change of ordering of attributes in header
210
- 'test/testcases/span/extension/comment.text', # bc of comment text modifications (can this be avoided?)
211
- 'test/testcases/block/04_header/header_type_offset.text', # bc of header_offset being applied twice
212
- ('test/testcases/block/04_header/with_auto_ids.text' if RUBY_VERSION <= '1.8.6'), # bc of dep stringex not working
213
- ('test/testcases/span/03_codespan/rouge/simple.text' if RUBY_VERSION < '2.0'), #bc of rouge
214
- ('test/testcases/span/03_codespan/rouge/disabled.text' if RUBY_VERSION < '2.0'), #bc of rouge
215
- 'test/testcases/block/06_codeblock/rouge/simple.text',
216
- 'test/testcases/block/06_codeblock/rouge/multiple.text', # check, what document contain more, than one code block
217
- 'test/testcases/block/14_table/empty_tag_in_cell.text', # bc of tidy
218
- 'test/testcases/block/15_math/ritex.text', # bc of tidy
219
- 'test/testcases/span/math/ritex.text', # bc of tidy
220
- 'test/testcases/block/15_math/itex2mml.text', # bc of tidy
221
- 'test/testcases/span/math/itex2mml.text', # bc of tidy
222
- 'test/testcases/block/15_math/mathjaxnode.text', # bc of tidy
223
- 'test/testcases/block/15_math/mathjaxnode_notexhints.text', # bc of tidy
224
- 'test/testcases/block/15_math/mathjaxnode_semantics.text', # bc of tidy
225
- 'test/testcases/span/math/mathjaxnode.text', # bc of tidy
226
- 'test/testcases/block/15_math/sskatex.text', # bc of tidy
227
- 'test/testcases/span/math/sskatex.text', # bc of tidy
228
- 'test/testcases/block/15_math/katex.text', # bc of tidy
229
- 'test/testcases/span/math/katex.text', # bc of tidy
230
- 'test/testcases/span/01_link/link_defs_with_ial.text', # bc of attribute ordering
231
- 'test/testcases/span/05_html/mark_element.text', # bc of tidy
232
- 'test/testcases/block/09_html/xml.text', # bc of tidy
233
- 'test/testcases/span/05_html/xml.text', # bc of tidy
234
- ].compact
160
+ EXCLUDE_TEXT_FILES = [
161
+ 'test/testcases/span/05_html/markdown_attr.text', # bc of markdown attr
162
+ 'test/testcases/block/09_html/markdown_attr.text', # bc of markdown attr
163
+ 'test/testcases/span/extension/options.text', # bc of parse_span_html option
164
+ 'test/testcases/block/12_extension/options.text', # bc of options option
165
+ 'test/testcases/block/12_extension/options3.text', # bc of options option
166
+ 'test/testcases/block/09_html/content_model/tables.text', # bc of parse_block_html option
167
+ 'test/testcases/block/09_html/html_to_native/header.text', # bc of auto_ids option that interferes
168
+ 'test/testcases/block/09_html/html_to_native/table_simple.text', # bc of tr style attr getting removed
169
+ 'test/testcases/block/09_html/simple.text', # bc of webgen:block elements
170
+ 'test/testcases/block/11_ial/simple.text', # bc of change of ordering of attributes in header
171
+ 'test/testcases/span/extension/comment.text', # bc of comment text modifications (can this be avoided?)
172
+ 'test/testcases/block/04_header/header_type_offset.text', # bc of header_offset being applied twice
173
+ 'test/testcases/block/06_codeblock/rouge/simple.text',
174
+ 'test/testcases/block/06_codeblock/rouge/multiple.text', # check, what document contain more, than one code block
175
+ 'test/testcases/block/14_table/empty_tag_in_cell.text', # bc of tidy
176
+ 'test/testcases/span/01_link/link_defs_with_ial.text', # bc of attribute ordering
177
+ 'test/testcases/span/05_html/mark_element.text', # bc of tidy
178
+ 'test/testcases/block/09_html/xml.text', # bc of tidy
179
+ 'test/testcases/span/05_html/xml.text', # bc of tidy
180
+ ].compact
235
181
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
236
- next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/}
182
+ next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/ }
237
183
  html_file = text_file.sub(/\.text$/, '.html')
238
- html_file += '.19' if RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')
239
184
  next unless File.exist?(html_file)
240
185
  define_method('test_' + text_file.tr('.', '_') + "_to_kramdown_to_html") do
241
186
  opts_file = text_file.sub(/\.text$/, '.options')
242
- opts_file = File.join(File.dirname(text_file), 'options') if !File.exist?(opts_file)
243
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
187
+ opts_file = File.join(File.dirname(text_file), 'options') unless File.exist?(opts_file)
188
+ options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
244
189
  kdtext = Kramdown::Document.new(File.read(text_file), options).to_kramdown
245
190
  html = Kramdown::Document.new(kdtext, options).to_html
246
191
  assert_equal(tidy_output(File.read(html_file)), tidy_output(html))
@@ -253,53 +198,42 @@ class TestFiles < Minitest::Test
253
198
  if $?.exitstatus != 0
254
199
  warn("Skipping html-to-kramdown-to-html tests because tidy executable is missing")
255
200
  else
256
- EXCLUDE_HTML_KD_FILES = ['test/testcases/span/extension/options.html', # bc of parse_span_html option
257
- 'test/testcases/span/05_html/normal.html', # bc of br tag before closing p tag
258
- 'test/testcases/block/12_extension/nomarkdown.html', # bc of nomarkdown extension
259
- 'test/testcases/block/09_html/simple.html', # bc of webgen:block elements
260
- 'test/testcases/block/09_html/markdown_attr.html', # bc of markdown attr
261
- 'test/testcases/block/09_html/html_to_native/table_simple.html', # bc of invalidly converted simple table
262
- 'test/testcases/block/06_codeblock/whitespace.html', # bc of entity to char conversion
263
- 'test/testcases/block/06_codeblock/rouge/simple.html', # bc of double surrounding <div>
264
- 'test/testcases/block/06_codeblock/rouge/multiple.html', # bc of double surrounding <div>
265
- 'test/testcases/block/11_ial/simple.html', # bc of change of ordering of attributes in header
266
- 'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element
267
- 'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option
268
- 'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option
269
- 'test/testcases/block/16_toc/toc_exclude.html', # bc of different attribute ordering
270
- 'test/testcases/span/autolinks/url_links.html', # bc of quot entity being converted to char
271
- ('test/testcases/span/03_codespan/rouge/simple.html' if RUBY_VERSION < '2.0'),
272
- ('test/testcases/span/03_codespan/rouge/disabled.html' if RUBY_VERSION < '2.0'),
273
- 'test/testcases/block/14_table/empty_tag_in_cell.html', # bc of tidy
274
- 'test/testcases/block/15_math/ritex.html', # bc of tidy
275
- 'test/testcases/span/math/ritex.html', # bc of tidy
276
- 'test/testcases/block/15_math/itex2mml.html', # bc of tidy
277
- 'test/testcases/span/math/itex2mml.html', # bc of tidy
278
- 'test/testcases/block/15_math/mathjaxnode.html', # bc of tidy
279
- 'test/testcases/block/15_math/mathjaxnode_notexhints.html', # bc of tidy
280
- 'test/testcases/block/15_math/mathjaxnode_semantics.html', # bc of tidy
281
- 'test/testcases/span/math/mathjaxnode.html', # bc of tidy
282
- 'test/testcases/block/15_math/sskatex.html', # bc of tidy
283
- 'test/testcases/span/math/sskatex.html', # bc of tidy
284
- 'test/testcases/block/15_math/katex.html', # bc of tidy
285
- 'test/testcases/span/math/katex.html', # bc of tidy
286
- 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
287
- 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
288
- 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview
289
- 'test/testcases/span/01_link/link_defs_with_ial.html', # bc of attribute ordering
290
- 'test/testcases/span/05_html/mark_element.html', # bc of tidy
291
- 'test/testcases/block/09_html/xml.html', # bc of tidy
292
- 'test/testcases/span/05_html/xml.html', # bc of tidy
293
- ].compact
294
- Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,html.19}'].each do |html_file|
295
- next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
296
- next if (RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')) ||
297
- (RUBY_VERSION < '1.9' && html_file =~ /\.19$/)
201
+ EXCLUDE_HTML_KD_FILES = [
202
+ 'test/testcases/span/extension/options.html', # bc of parse_span_html option
203
+ 'test/testcases/span/05_html/normal.html', # bc of br tag before closing p tag
204
+ 'test/testcases/block/12_extension/nomarkdown.html', # bc of nomarkdown extension
205
+ 'test/testcases/block/12_extension/options3.html', # bc of rouge
206
+ 'test/testcases/block/09_html/simple.html', # bc of webgen:block elements
207
+ 'test/testcases/block/09_html/markdown_attr.html', # bc of markdown attr
208
+ 'test/testcases/block/09_html/html_to_native/table_simple.html', # bc of invalidly converted simple table
209
+ 'test/testcases/block/06_codeblock/whitespace.html', # bc of entity to char conversion
210
+ 'test/testcases/block/06_codeblock/rouge/simple.html', # bc of double surrounding <div>
211
+ 'test/testcases/block/06_codeblock/rouge/multiple.html', # bc of double surrounding <div>
212
+ 'test/testcases/block/06_codeblock/highlighting.html', # bc of span elements inside code element
213
+ 'test/testcases/block/06_codeblock/highlighting-opts.html', # bc of span elements inside code element
214
+ 'test/testcases/block/11_ial/simple.html', # bc of change of ordering of attributes in header
215
+ 'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element
216
+ 'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option
217
+ 'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option
218
+ 'test/testcases/block/16_toc/toc_exclude.html', # bc of different attribute ordering
219
+ 'test/testcases/span/autolinks/url_links.html', # bc of quot entity being converted to char
220
+ 'test/testcases/block/14_table/empty_tag_in_cell.html', # bc of tidy
221
+ 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
222
+ 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
223
+ 'test/testcases/block/15_math/mathjax_preview_as_code.html', # bc of mathjax preview
224
+ 'test/testcases/span/01_link/link_defs_with_ial.html', # bc of attribute ordering
225
+ 'test/testcases/span/05_html/mark_element.html', # bc of tidy
226
+ 'test/testcases/block/09_html/xml.html', # bc of tidy
227
+ 'test/testcases/span/05_html/xml.html', # bc of tidy
228
+ ].compact
229
+ Dir[File.dirname(__FILE__) + '/testcases/**/*.html'].each do |html_file|
230
+ next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}$/ }
298
231
  define_method('test_' + html_file.tr('.', '_') + "_to_kramdown_to_html") do
299
- kd = Kramdown::Document.new(File.read(html_file), :input => 'html', :auto_ids => false, :footnote_nr => 1).to_kramdown
300
- opts_file = html_file.sub(/\.html(\.19)?$/, '.options')
301
- opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file)
302
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
232
+ kd = Kramdown::Document.new(File.read(html_file), input: 'html',
233
+ auto_ids: false, footnote_nr: 1).to_kramdown
234
+ opts_file = html_file.sub(/\.html$/, '.options')
235
+ opts_file = File.join(File.dirname(html_file), 'options') unless File.exist?(opts_file)
236
+ options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
303
237
  doc = Kramdown::Document.new(kd, options)
304
238
  assert_equal(tidy_output(File.read(html_file)), tidy_output(doc.to_html))
305
239
  end
@@ -310,132 +244,22 @@ class TestFiles < Minitest::Test
310
244
  Dir[File.dirname(__FILE__) + '/testcases/man/**/*.text'].each do |text_file|
311
245
  define_method('test_' + text_file.tr('.', '_') + "_to_man") do
312
246
  man_file = text_file.sub(/\.text$/, '.man')
313
- doc = Kramdown::Document.new(File.read(text_file))
247
+ doc = Kramdown::Document.new(File.read(text_file))
314
248
  assert_equal(File.read(man_file), doc.to_man)
315
249
  end
316
250
  end
317
251
 
318
- EXCLUDE_GFM_FILES = [
319
- 'test/testcases/block/03_paragraph/no_newline_at_end.text',
320
- 'test/testcases/block/03_paragraph/indented.text',
321
- 'test/testcases/block/03_paragraph/two_para.text',
322
- 'test/testcases/block/03_paragraph/line_break_last_line.text',
323
- 'test/testcases/block/04_header/atx_header.text',
324
- 'test/testcases/block/04_header/setext_header.text',
325
- 'test/testcases/block/04_header/with_auto_ids.text', # bc of ID generation difference
326
- 'test/testcases/block/04_header/with_auto_id_prefix.text', # bc of ID generation difference
327
- 'test/testcases/block/05_blockquote/indented.text',
328
- 'test/testcases/block/05_blockquote/lazy.text',
329
- 'test/testcases/block/05_blockquote/nested.text',
330
- 'test/testcases/block/05_blockquote/no_newline_at_end.text',
331
- 'test/testcases/block/06_codeblock/error.text',
332
- 'test/testcases/block/07_horizontal_rule/error.text',
333
- 'test/testcases/block/08_list/escaping.text',
334
- 'test/testcases/block/08_list/item_ial.text',
335
- 'test/testcases/block/08_list/lazy.text',
336
- 'test/testcases/block/08_list/list_and_others.text',
337
- 'test/testcases/block/08_list/other_first_element.text',
338
- 'test/testcases/block/08_list/simple_ul.text',
339
- 'test/testcases/block/08_list/special_cases.text',
340
- 'test/testcases/block/08_list/lazy_and_nested.text', # bc of change in lazy line handling
341
- 'test/testcases/block/09_html/comment.text',
342
- 'test/testcases/block/09_html/html_to_native/code.text',
343
- 'test/testcases/block/09_html/html_to_native/emphasis.text',
344
- 'test/testcases/block/09_html/html_to_native/typography.text',
345
- 'test/testcases/block/09_html/parse_as_raw.text',
346
- 'test/testcases/block/09_html/simple.text',
347
- 'test/testcases/block/12_extension/comment.text',
348
- 'test/testcases/block/12_extension/ignored.text',
349
- 'test/testcases/block/12_extension/nomarkdown.text',
350
- 'test/testcases/block/13_definition_list/item_ial.text',
351
- 'test/testcases/block/13_definition_list/multiple_terms.text',
352
- 'test/testcases/block/13_definition_list/no_def_list.text',
353
- 'test/testcases/block/13_definition_list/simple.text',
354
- 'test/testcases/block/13_definition_list/with_blocks.text',
355
- 'test/testcases/block/14_table/errors.text',
356
- 'test/testcases/block/14_table/escaping.text',
357
- 'test/testcases/block/14_table/simple.text',
358
- 'test/testcases/block/15_math/normal.text',
359
- 'test/testcases/block/16_toc/toc_with_footnotes.text', # bc of ID generation difference
360
- 'test/testcases/encoding.text',
361
- 'test/testcases/span/01_link/inline.text',
362
- 'test/testcases/span/01_link/link_defs.text',
363
- 'test/testcases/span/01_link/reference.text',
364
- 'test/testcases/span/02_emphasis/normal.text',
365
- 'test/testcases/span/03_codespan/normal.text',
366
- 'test/testcases/span/04_footnote/definitions.text',
367
- 'test/testcases/span/04_footnote/markers.text',
368
- 'test/testcases/span/05_html/across_lines.text',
369
- 'test/testcases/span/05_html/markdown_attr.text',
370
- 'test/testcases/span/05_html/normal.text',
371
- 'test/testcases/span/05_html/raw_span_elements.text',
372
- 'test/testcases/span/autolinks/url_links.text',
373
- 'test/testcases/span/extension/comment.text',
374
- 'test/testcases/span/ial/simple.text',
375
- 'test/testcases/span/line_breaks/normal.text',
376
- 'test/testcases/span/math/normal.text',
377
- 'test/testcases/span/text_substitutions/entities_as_char.text',
378
- 'test/testcases/span/text_substitutions/entities.text',
379
- 'test/testcases/span/text_substitutions/typography.text',
380
- ('test/testcases/span/03_codespan/rouge/simple.text' if RUBY_VERSION < '2.0'),
381
- ('test/testcases/span/03_codespan/rouge/disabled.text' if RUBY_VERSION < '2.0'),
382
- ('test/testcases/block/06_codeblock/rouge/simple.text' if RUBY_VERSION < '2.0'), #bc of rouge
383
- ('test/testcases/block/06_codeblock/rouge/disabled.text' if RUBY_VERSION < '2.0'), #bc of rouge
384
- ('test/testcases/block/06_codeblock/rouge/multiple.text' if RUBY_VERSION < '2.0'), #bc of rouge
385
- ('test/testcases/block/15_math/itex2mml.text' if RUBY_PLATFORM == 'java'), # bc of itextomml
386
- ('test/testcases/span/math/itex2mml.text' if RUBY_PLATFORM == 'java'), # bc of itextomml
387
- ('test/testcases/block/15_math/mathjaxnode.text' unless MATHJAX_NODE_AVAILABLE),
388
- ('test/testcases/block/15_math/mathjaxnode_notexhints.text' unless MATHJAX_NODE_AVAILABLE),
389
- ('test/testcases/block/15_math/mathjaxnode_semantics.text' unless MATHJAX_NODE_AVAILABLE),
390
- ('test/testcases/span/math/mathjaxnode.text' unless MATHJAX_NODE_AVAILABLE),
391
- ('test/testcases/block/15_math/sskatex.text' unless SSKATEX_AVAILABLE),
392
- ('test/testcases/span/math/sskatex.text' unless SSKATEX_AVAILABLE),
393
- ('test/testcases/block/15_math/katex.text' unless KATEX_AVAILABLE),
394
- ('test/testcases/span/math/katex.text' unless KATEX_AVAILABLE),
395
- ].compact
396
-
397
- # Generate test methods for gfm-to-html conversion
398
- Dir[File.dirname(__FILE__) + '/{testcases,testcases_gfm}/**/*.text'].each do |text_file|
399
- next if EXCLUDE_GFM_FILES.any? {|f| text_file =~ /#{f}$/}
400
- basename = text_file.sub(/\.text$/, '')
401
-
402
- html_file = [(".html.19" if RUBY_VERSION >= '1.9'), ".html"].compact.
403
- map {|ext| basename + ext }.
404
- detect {|file| File.exist?(file) }
405
- next unless html_file
406
-
407
- define_method('test_gfm_' + text_file.tr('.', '_') + "_to_html") do
408
- opts_file = basename + '.options'
409
- opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file)
410
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
411
- doc = Kramdown::Document.new(File.read(text_file), options.merge(:input => 'GFM'))
412
- assert_equal(File.read(html_file), doc.to_html)
413
- end
414
- end
415
-
416
-
417
- EXCLUDE_PDF_MODIFY = ['test/testcases/span/text_substitutions/entities.text',
418
- 'test/testcases/span/text_substitutions/entities_numeric.text',
419
- 'test/testcases/span/text_substitutions/entities_as_char.text',
420
- 'test/testcases/span/text_substitutions/entities_as_input.text',
421
- 'test/testcases/span/text_substitutions/entities_symbolic.text',
422
- 'test/testcases/block/04_header/with_auto_ids.text',
423
- ].compact
424
-
425
- EXCLUDE_MODIFY = ['test/testcases/block/06_codeblock/rouge/multiple.text', # bc of HTMLFormater in options
426
- ('test/testcases/block/15_math/sskatex.text' unless SSKATEX_AVAILABLE),
427
- ('test/testcases/span/math/sskatex.text' unless SSKATEX_AVAILABLE),
428
- ('test/testcases/block/15_math/katex.text' unless KATEX_AVAILABLE),
429
- ('test/testcases/span/math/katex.text' unless KATEX_AVAILABLE),
430
- ].compact
252
+ EXCLUDE_MODIFY = [
253
+ 'test/testcases/block/06_codeblock/rouge/multiple.text', # bc of HTMLFormater in options
254
+ ].compact
431
255
 
432
256
  # Generate test methods for asserting that converters don't modify the document tree.
433
257
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
434
258
  opts_file = text_file.sub(/\.text$/, '.options')
435
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
436
- (Kramdown::Converter.constants.map {|c| c.to_sym} - [:Base, :RemoveHtmlTags, :MathEngine, :SyntaxHighlighter]).each do |conv_class|
437
- next if EXCLUDE_MODIFY.any? {|f| text_file =~ /#{f}$/}
438
- next if conv_class == :Pdf && (RUBY_VERSION < '2.0' || EXCLUDE_PDF_MODIFY.any? {|f| text_file =~ /#{f}$/})
259
+ options = File.exist?(opts_file) ? YAML.load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
260
+ (Kramdown::Converter.constants.map(&:to_sym) -
261
+ [:Base, :RemoveHtmlTags, :MathEngine, :SyntaxHighlighter]).each do |conv_class|
262
+ next if EXCLUDE_MODIFY.any? {|f| text_file =~ /#{f}$/ }
439
263
  define_method("test_whether_#{conv_class}_modifies_tree_with_file_#{text_file.tr('.', '_')}") do
440
264
  doc = Kramdown::Document.new(File.read(text_file), options)
441
265
  options_before = Marshal.load(Marshal.dump(doc.options))