kramdown 1.4.2 → 1.5.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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +2 -1
  3. data/Rakefile +3 -0
  4. data/VERSION +1 -1
  5. data/doc/documentation.template +7 -0
  6. data/doc/sidebar.template +2 -2
  7. data/doc/virtual +9 -0
  8. data/lib/kramdown/converter.rb +39 -0
  9. data/lib/kramdown/converter/base.rb +28 -0
  10. data/lib/kramdown/converter/html.rb +25 -31
  11. data/lib/kramdown/converter/math_engine/itex2mml.rb +39 -0
  12. data/lib/kramdown/converter/math_engine/mathjax.rb +33 -0
  13. data/lib/kramdown/converter/math_engine/ritex.rb +38 -0
  14. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +78 -0
  15. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +37 -0
  16. data/lib/kramdown/element.rb +5 -5
  17. data/lib/kramdown/options.rb +96 -11
  18. data/lib/kramdown/parser/gfm.rb +5 -2
  19. data/lib/kramdown/parser/html.rb +3 -2
  20. data/lib/kramdown/utils.rb +18 -0
  21. data/lib/kramdown/utils/configurable.rb +44 -0
  22. data/lib/kramdown/version.rb +1 -1
  23. data/man/man1/kramdown.1 +62 -0
  24. data/test/test_files.rb +80 -56
  25. data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -0
  26. data/test/testcases/block/06_codeblock/highlighting-opts.options +7 -0
  27. data/test/testcases/block/06_codeblock/highlighting-opts.text +4 -0
  28. data/test/testcases/block/06_codeblock/highlighting-rouge.html +6 -0
  29. data/test/testcases/block/06_codeblock/highlighting-rouge.options +3 -0
  30. data/test/testcases/block/06_codeblock/highlighting-rouge.text +4 -0
  31. data/test/testcases/block/06_codeblock/highlighting.html +2 -2
  32. data/test/testcases/block/12_extension/options3.html +2 -2
  33. data/test/testcases/block/15_math/itex2mml.html +1 -0
  34. data/test/testcases/block/15_math/itex2mml.options +1 -0
  35. data/test/testcases/block/15_math/itex2mml.text +1 -0
  36. data/test/testcases/block/15_math/ritex.html +1 -0
  37. data/test/testcases/block/15_math/ritex.options +1 -0
  38. data/test/testcases/block/15_math/ritex.text +1 -0
  39. data/test/testcases/span/03_codespan/highlighting-rouge.html +1 -0
  40. data/test/testcases/span/03_codespan/highlighting-rouge.options +1 -0
  41. data/test/testcases/span/03_codespan/highlighting-rouge.text +1 -0
  42. data/test/testcases/span/03_codespan/highlighting.html +1 -1
  43. data/test/testcases/span/05_html/button.html +7 -0
  44. data/test/testcases/span/05_html/button.text +7 -0
  45. data/test/testcases/span/math/itex2mml.html +1 -0
  46. data/test/testcases/span/math/itex2mml.options +1 -0
  47. data/test/testcases/span/math/itex2mml.text +1 -0
  48. data/test/testcases/span/math/ritex.html +1 -0
  49. data/test/testcases/span/math/ritex.options +1 -0
  50. data/test/testcases/span/math/ritex.text +1 -0
  51. data/test/testcases_gfm/backticks_syntax.html +2 -2
  52. data/test/testcases_gfm/hard_line_breaks.html +3 -0
  53. data/test/testcases_gfm/hard_line_breaks.text +3 -0
  54. metadata +75 -2
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2014 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ module Kramdown::Converter::SyntaxHighlighter
11
+
12
+ # Uses Rouge which is CSS-compatible to Pygments to highlight code blocks and code spans.
13
+ module Rouge
14
+
15
+ begin
16
+ require 'rouge'
17
+
18
+ # Highlighting via Rouge is available if this constant is +true+.
19
+ AVAILABLE = true
20
+ rescue LoadError, SyntaxError
21
+ AVAILABLE = false # :nodoc:
22
+ end
23
+
24
+ def self.call(converter, text, lang, type, _unused_opts)
25
+ opts = converter.options[:syntax_highlighter_opts].dup
26
+ lexer = ::Rouge::Lexer.find_fancy(lang || opts[:default_lang], text)
27
+ return nil unless lexer
28
+
29
+ opts[:wrap] = false if type == :span
30
+
31
+ formatter = ::Rouge::Formatters::HTML.new(opts)
32
+ formatter.format(lexer.lex(text))
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -116,7 +116,7 @@ module Kramdown
116
116
  #
117
117
  # === :li
118
118
  #
119
- # [Category] None
119
+ # [Category] Block-level element
120
120
  # [Usage context] Inside :ol and :ul elements
121
121
  # [Content model] Block-level elements
122
122
  #
@@ -137,7 +137,7 @@ module Kramdown
137
137
  #
138
138
  # === :dt
139
139
  #
140
- # [Category] None
140
+ # [Category] Block-level element
141
141
  # [Usage context] Before :dt or :dd elements inside a :dl elment
142
142
  # [Content model] Span-level elements
143
143
  #
@@ -146,7 +146,7 @@ module Kramdown
146
146
  #
147
147
  # === :dd
148
148
  #
149
- # [Category] None
149
+ # [Category] Block-level element
150
150
  # [Usage context] After :dt or :dd elements inside a :dl elment
151
151
  # [Content model] Block-level elements
152
152
  #
@@ -214,7 +214,7 @@ module Kramdown
214
214
  #
215
215
  # === :td
216
216
  #
217
- # [Category] None
217
+ # [Category] Block-level element
218
218
  # [Usage context] Inside :tr elements
219
219
  # [Content model] As child of :thead/:tr span-level elements, as child of :tbody/:tr and
220
220
  # :tfoot/:tr block-level elements
@@ -498,7 +498,7 @@ module Kramdown
498
498
  end
499
499
 
500
500
  CATEGORY = {} # :nodoc:
501
- [:blank, :p, :header, :blockquote, :codeblock, :ul, :ol, :dl, :table, :hr].each {|b| CATEGORY[b] = :block}
501
+ [:blank, :p, :header, :blockquote, :codeblock, :ul, :ol, :li, :dl, :dt, :dd, :table, :td, :hr].each {|b| CATEGORY[b] = :block}
502
502
  [:text, :a, :br, :img, :codespan, :footnote, :em, :strong, :entity, :typographic_sym,
503
503
  :smart_quote, :abbreviation].each {|b| CATEGORY[b] = :span}
504
504
 
@@ -101,9 +101,7 @@ module Kramdown
101
101
  elsif @options[name].type == Float
102
102
  Float(data) rescue raise Kramdown::Error, "Invalid float value for option '#{name}': '#{data}'"
103
103
  elsif @options[name].type == Symbol
104
- data.strip!
105
- data = data[1..-1] if data[0] == ?:
106
- (data.empty? || data == 'nil' ? nil : data.to_sym)
104
+ str_to_sym(data)
107
105
  elsif @options[name].type == Boolean
108
106
  data.downcase.strip != 'false' && !data.empty?
109
107
  end
@@ -112,6 +110,17 @@ module Kramdown
112
110
  data
113
111
  end
114
112
 
113
+ # Converts the given String +data+ into a Symbol or +nil+ with the
114
+ # following provisions:
115
+ #
116
+ # - A leading colon is stripped from the string.
117
+ # - An empty value or a value equal to "nil" results in +nil+.
118
+ def self.str_to_sym(data)
119
+ data = data.strip
120
+ data = data[1..-1] if data[0] == ?:
121
+ (data.empty? || data == 'nil' ? nil : data.to_sym)
122
+ end
123
+
115
124
  # ----------------------------
116
125
  # :section: Option Validators
117
126
  #
@@ -137,6 +146,23 @@ module Kramdown
137
146
  val
138
147
  end
139
148
 
149
+ # Ensures that the option value +val+ for the option called +name+ is a valid hash. The
150
+ # parameter +val+ can be
151
+ #
152
+ # - a hash in YAML format
153
+ # - or a Ruby Hash object.
154
+ def self.simple_hash_validator(val, name)
155
+ if String === val
156
+ begin
157
+ val = YAML.load(val)
158
+ rescue RuntimeError, ArgumentError, SyntaxError
159
+ raise Kramdown::Error, "Invalid YAML value for option #{name}"
160
+ end
161
+ end
162
+ raise Kramdown::Error, "Invalid type #{val.class} for option #{name}" if !(Hash === val)
163
+ val
164
+ end
165
+
140
166
  # ----------------------------
141
167
  # :section: Option Definitions
142
168
  #
@@ -269,14 +295,7 @@ hash has to follow the above guidelines.
269
295
  Default: {}
270
296
  Used by: kramdown parser
271
297
  EOF
272
- if String === val
273
- begin
274
- val = YAML.load(val)
275
- rescue RuntimeError, ArgumentError, SyntaxError
276
- raise Kramdown::Error, "Invalid YAML value for option link_defs"
277
- end
278
- end
279
- raise Kramdown::Error, "Invalid type #{val.class} for option #{name}" if !(Hash === val)
298
+ val = simple_hash_validator(val, :link_defs)
280
299
  val.each do |k,v|
281
300
  if !(Array === v) || v.size > 2 || v.size < 1
282
301
  raise Kramdown::Error, "Invalid structure for hash value of option #{name}"
@@ -494,6 +513,72 @@ Default: true
494
513
  Used by: GFM parser
495
514
  EOF
496
515
 
516
+ define(:syntax_highlighter, Symbol, :coderay, <<EOF)
517
+ Set the syntax highlighter
518
+
519
+ Specifies the syntax highlighter that should be used for highlighting
520
+ code blocks and spans. If this option is set to +nil+, no syntax
521
+ highlighting is done.
522
+
523
+ Options for the syntax highlighter can be set with the
524
+ syntax_highlighter_opts configuration option.
525
+
526
+ Default: coderay
527
+ Used by: HTML converter
528
+ EOF
529
+
530
+ define(:syntax_highlighter_opts, Object, {}, <<EOF) do |val|
531
+ Set the syntax highlighter options
532
+
533
+ Specifies options for the syntax highlighter set via the
534
+ syntax_highlighter configuration option.
535
+
536
+ The value needs to be a hash with key-value pairs that are understood by
537
+ the used syntax highlighter.
538
+
539
+ Default: {}
540
+ Used by: HTML converter
541
+ EOF
542
+ val = simple_hash_validator(val, :syntax_highlighter_opts)
543
+ val.keys.each do |k|
544
+ val[k.kind_of?(String) ? str_to_sym(k) : k] = val.delete(k)
545
+ end
546
+ val
547
+ end
548
+
549
+ define(:math_engine, Symbol, :mathjax, <<EOF)
550
+ Set the math engine
551
+
552
+ Specifies the math engine that should be used for converting math
553
+ blocks/spans. If this option is set to +nil+, no math engine is used and
554
+ the math blocks/spans are output as is.
555
+
556
+ Options for the selected math engine can be set with the
557
+ math_engine_opts configuration option.
558
+
559
+ Default: mathjax
560
+ Used by: HTML converter
561
+ EOF
562
+
563
+ define(:math_engine_opts, Object, {}, <<EOF) do |val|
564
+ Set the math engine options
565
+
566
+ Specifies options for the math engine set via the math_engine
567
+ configuration option.
568
+
569
+ The value needs to be a hash with key-value pairs that are understood by
570
+ the used math engine.
571
+
572
+ Default: {}
573
+ Used by: HTML converter
574
+ EOF
575
+ val = simple_hash_validator(val, :math_engine_opts)
576
+ val.keys.each do |k|
577
+ val[k.kind_of?(String) ? str_to_sym(k) : k] = val.delete(k)
578
+ end
579
+ val
580
+ end
581
+
497
582
  end
498
583
 
499
584
  end
@@ -26,10 +26,13 @@ module Kramdown
26
26
  element.children.map! do |child|
27
27
  if child.type == :text && child.value =~ /\n/
28
28
  children = []
29
- lines = child.value.split(/\n(?=.)/)
29
+ lines = child.value.split(/\n/, -1)
30
+ omit_trailing_br = (Kramdown::Element.category(element) == :block && element.children[-1] == child &&
31
+ lines[-1].empty?)
30
32
  lines.each_with_index do |line, index|
31
33
  children << Element.new(:text, (index > 0 ? "\n#{line}" : line))
32
- children << Element.new(:br) if index < lines.size - 1
34
+ children << Element.new(:br) if index < lines.size - 2 ||
35
+ (index == lines.size - 2 && !omit_trailing_br)
33
36
  end
34
37
  children
35
38
  elsif child.type == :html_element
@@ -33,7 +33,7 @@ module Kramdown
33
33
  HTML_TAG_CLOSE_RE = /<\/(#{REXML::Parsers::BaseParser::UNAME_STR})\s*>/m
34
34
  HTML_ENTITY_RE = /&([\w:][\-\w\.:]*);|&#(\d+);|&\#x([0-9a-fA-F]+);/
35
35
 
36
- HTML_CONTENT_MODEL_BLOCK = %w{address applet article aside button blockquote body
36
+ HTML_CONTENT_MODEL_BLOCK = %w{address applet article aside blockquote body
37
37
  dd details div dl fieldset figure figcaption footer form header hgroup iframe li map menu nav
38
38
  noscript object section summary td}
39
39
  HTML_CONTENT_MODEL_SPAN = %w{a abbr acronym b bdo big button cite caption del dfn dt em
@@ -54,7 +54,7 @@ module Kramdown
54
54
  HTML_SPAN_ELEMENTS = %w{a abbr acronym b big bdo br button cite code del dfn em i img input
55
55
  ins kbd label option q rb rbc rp rt rtc ruby samp select small span
56
56
  strong sub sup tt u var}
57
- HTML_BLOCK_ELEMENTS = %w{address article aside applet body button blockquote caption col colgroup dd div dl dt fieldset
57
+ HTML_BLOCK_ELEMENTS = %w{address article aside applet body blockquote caption col colgroup dd div dl dt fieldset
58
58
  figcaption footer form h1 h2 h3 h4 h5 h6 header hgroup hr html head iframe legend menu
59
59
  li map nav ol optgroup p pre section summary table tbody td th thead tfoot tr ul}
60
60
  HTML_ELEMENTS_WITHOUT_BODY = %w{area base br col command embed hr img input keygen link meta param source track wbr}
@@ -403,6 +403,7 @@ module Kramdown
403
403
  else
404
404
  if el.value == 'code'
405
405
  set_basics(el, :codespan)
406
+ el.attr['class'].gsub!(/\s+\bhighlighter-\w+\b|\bhighlighter-\w+\b\s*/, '') if el.attr['class']
406
407
  else
407
408
  set_basics(el, :codeblock)
408
409
  if el.children.size == 1 && el.children.first.value == 'code'
@@ -20,6 +20,7 @@ module Kramdown
20
20
  autoload :OrderedHash, 'kramdown/utils/ordered_hash'
21
21
  autoload :Unidecoder, 'kramdown/utils/unidecoder'
22
22
  autoload :StringScanner, 'kramdown/utils/string_scanner'
23
+ autoload :Configurable, 'kramdown/utils/configurable'
23
24
 
24
25
  # Treat +name+ as if it were snake cased (e.g. snake_case) and camelize it (e.g. SnakeCase).
25
26
  def self.camelize(name)
@@ -35,6 +36,23 @@ module Kramdown
35
36
  name
36
37
  end
37
38
 
39
+ if RUBY_VERSION < '2.0'
40
+
41
+ # Resolve the recursive constant +str+.
42
+ def self.deep_const_get(str)
43
+ names = str.split(/::/)
44
+ names.shift if names.first.empty?
45
+ names.inject(::Object) {|mod, s| mod.const_get(s)}
46
+ end
47
+
48
+ else
49
+
50
+ def self.deep_const_get(str)
51
+ ::Object.const_get(str)
52
+ end
53
+
54
+ end
55
+
38
56
  end
39
57
 
40
58
  end
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2014 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ module Kramdown
11
+ module Utils
12
+
13
+ # Methods for registering configurable extensions.
14
+ module Configurable
15
+
16
+ # Create a new configurable extension called +name+.
17
+ #
18
+ # Three methods will be defined on the calling object which allow to use this configurable
19
+ # extension:
20
+ #
21
+ # configurables:: Returns a hash of hashes that is used to store all configurables of the
22
+ # object.
23
+ #
24
+ # <name>(ext_name):: Return the configured extension +ext_name+.
25
+ #
26
+ # add_<name>(ext_name, data=nil, &block):: Define an extension +ext_name+ by specifying either
27
+ # the data as argument or by using a block.
28
+ def configurable(name)
29
+ singleton_class = (class << self; self; end)
30
+ singleton_class.send(:define_method, :configurables) do
31
+ @_configurables ||= Hash.new {|h, k| h[k] = {}}
32
+ end
33
+ singleton_class.send(:define_method, name) do |data|
34
+ configurables[name][data]
35
+ end
36
+ singleton_class.send(:define_method, "add_#{name}".intern) do |data, *args, &block|
37
+ configurables[name][data] = args.first || block
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
@@ -10,6 +10,6 @@
10
10
  module Kramdown
11
11
 
12
12
  # The kramdown version.
13
- VERSION = '1.4.2'
13
+ VERSION = '1.5.0'
14
14
 
15
15
  end
@@ -392,6 +392,68 @@ Default: true
392
392
  Used by: GFM parser
393
393
 
394
394
 
395
+ .TP
396
+ .B \-\-syntax-highlighter ARG
397
+
398
+ Set the syntax highlighter
399
+
400
+ Specifies the syntax highlighter that should be used for highlighting
401
+ code blocks and spans. If this option is set to +nil+, no syntax
402
+ highlighting is done.
403
+
404
+ Options for the syntax highlighter can be set with the
405
+ syntax_highlighter_opts configuration option.
406
+
407
+ Default: coderay
408
+ Used by: HTML converter
409
+
410
+
411
+ .TP
412
+ .B \-\-syntax-highlighter-opts ARG
413
+
414
+ Set the syntax highlighter options
415
+
416
+ Specifies options for the syntax highlighter set via the
417
+ syntax_highlighter configuration option.
418
+
419
+ The value needs to be a hash with key-value pairs that are understood by
420
+ the used syntax highlighter.
421
+
422
+ Default: {}
423
+ Used by: HTML converter
424
+
425
+
426
+ .TP
427
+ .B \-\-math-engine ARG
428
+
429
+ Set the math engine
430
+
431
+ Specifies the math engine that should be used for converting math
432
+ blocks/spans. If this option is set to +nil+, no math engine is used and
433
+ the math blocks/spans are output as is.
434
+
435
+ Options for the selected math engine can be set with the
436
+ math_engine_opts configuration option.
437
+
438
+ Default: mathjax
439
+ Used by: HTML converter
440
+
441
+
442
+ .TP
443
+ .B \-\-math-engine-opts ARG
444
+
445
+ Set the math engine options
446
+
447
+ Specifies options for the math engine set via the math_engine
448
+ configuration option.
449
+
450
+ The value needs to be a hash with key-value pairs that are understood by
451
+ the used math engine.
452
+
453
+ Default: {}
454
+ Used by: HTML converter
455
+
456
+
395
457
  .SH EXIT STATUS
396
458
  The exit status is 0 if no error happened. Otherwise it is 1.
397
459
  .SH SEE ALSO
@@ -17,6 +17,9 @@ Encoding.default_external = 'utf-8' if RUBY_VERSION >= '1.9'
17
17
  class TestFiles < Minitest::Test
18
18
 
19
19
  EXCLUDE_KD_FILES = [('test/testcases/block/04_header/with_auto_ids.text' if RUBY_VERSION <= '1.8.6'), # bc of dep stringex not working
20
+ ('test/testcases/span/03_codespan/highlighting-rouge.text' if RUBY_VERSION < '2.0'), #bc of rouge
21
+ ('test/testcases/block/06_codeblock/highlighting-rouge.text' if RUBY_VERSION < '2.0'), #bc of rouge
22
+
20
23
  ].compact
21
24
 
22
25
  # Generate test methods for kramdown-to-xxx conversion
@@ -48,6 +51,12 @@ class TestFiles < Minitest::Test
48
51
  'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element
49
52
  'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option
50
53
  'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option
54
+ 'test/testcases/block/06_codeblock/highlighting-rouge.html', # bc of double surrounding <div>
55
+ ('test/testcases/span/03_codespan/highlighting-rouge.html' if RUBY_VERSION < '2.0'),
56
+ 'test/testcases/block/15_math/ritex.html', # bc of tidy
57
+ 'test/testcases/span/math/ritex.html', # bc of tidy
58
+ 'test/testcases/block/15_math/itex2mml.html', # bc of tidy
59
+ 'test/testcases/span/math/itex2mml.html', # bc of tidy
51
60
  ]
52
61
  Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,html.19,htmlinput,htmlinput.19}'].each do |html_file|
53
62
  next if EXCLUDE_HTML_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
@@ -122,6 +131,12 @@ class TestFiles < Minitest::Test
122
131
  'test/testcases/span/extension/comment.text', # bc of comment text modifications (can this be avoided?)
123
132
  'test/testcases/block/04_header/header_type_offset.text', # bc of header_offset being applied twice
124
133
  ('test/testcases/block/04_header/with_auto_ids.text' if RUBY_VERSION <= '1.8.6'), # bc of dep stringex not working
134
+ ('test/testcases/span/03_codespan/highlighting-rouge.text' if RUBY_VERSION < '2.0'),
135
+ ('test/testcases/block/06_codeblock/highlighting-rouge.text' if RUBY_VERSION < '2.0'), #bc of rouge
136
+ 'test/testcases/block/15_math/ritex.text', # bc of tidy
137
+ 'test/testcases/span/math/ritex.text', # bc of tidy
138
+ 'test/testcases/block/15_math/itex2mml.text', # bc of tidy
139
+ 'test/testcases/span/math/itex2mml.text', # bc of tidy
125
140
  ].compact
126
141
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
127
142
  next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/}
@@ -150,12 +165,18 @@ class TestFiles < Minitest::Test
150
165
  'test/testcases/block/09_html/markdown_attr.html', # bc of markdown attr
151
166
  'test/testcases/block/09_html/html_to_native/table_simple.html', # bc of invalidly converted simple table
152
167
  'test/testcases/block/06_codeblock/whitespace.html', # bc of entity to char conversion
168
+ 'test/testcases/block/06_codeblock/highlighting-rouge.html', # bc of double surrounding <div>
153
169
  'test/testcases/block/11_ial/simple.html', # bc of change of ordering of attributes in header
154
170
  'test/testcases/span/03_codespan/highlighting.html', # bc of span elements inside code element
155
171
  'test/testcases/block/04_header/with_auto_ids.html', # bc of auto_ids=true option
156
172
  'test/testcases/block/04_header/header_type_offset.html', # bc of header_offset option
157
173
  'test/testcases/block/16_toc/toc_exclude.html', # bc of different attribute ordering
158
174
  'test/testcases/span/autolinks/url_links.html', # bc of quot entity being converted to char
175
+ ('test/testcases/span/03_codespan/highlighting-rouge.html' if RUBY_VERSION < '2.0'),
176
+ 'test/testcases/block/15_math/ritex.html', # bc of tidy
177
+ 'test/testcases/span/math/ritex.html', # bc of tidy
178
+ 'test/testcases/block/15_math/itex2mml.html', # bc of tidy
179
+ 'test/testcases/span/math/itex2mml.html', # bc of tidy
159
180
  ]
160
181
  Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,html.19}'].each do |html_file|
161
182
  next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
@@ -173,61 +194,64 @@ class TestFiles < Minitest::Test
173
194
  end
174
195
 
175
196
  EXCLUDE_GFM_FILES = [
176
- 'test/testcases/block/03_paragraph/no_newline_at_end.text',
177
- 'test/testcases/block/03_paragraph/indented.text',
178
- 'test/testcases/block/03_paragraph/two_para.text',
179
- 'test/testcases/block/04_header/atx_header.text',
180
- 'test/testcases/block/04_header/setext_header.text',
181
- 'test/testcases/block/05_blockquote/indented.text',
182
- 'test/testcases/block/05_blockquote/lazy.text',
183
- 'test/testcases/block/05_blockquote/nested.text',
184
- 'test/testcases/block/05_blockquote/no_newline_at_end.text',
185
- 'test/testcases/block/06_codeblock/error.text',
186
- 'test/testcases/block/07_horizontal_rule/error.text',
187
- 'test/testcases/block/08_list/escaping.text',
188
- 'test/testcases/block/08_list/item_ial.text',
189
- 'test/testcases/block/08_list/lazy.text',
190
- 'test/testcases/block/08_list/list_and_others.text',
191
- 'test/testcases/block/08_list/other_first_element.text',
192
- 'test/testcases/block/08_list/simple_ul.text',
193
- 'test/testcases/block/08_list/special_cases.text',
194
- 'test/testcases/block/09_html/comment.text',
195
- 'test/testcases/block/09_html/html_to_native/code.text',
196
- 'test/testcases/block/09_html/html_to_native/emphasis.text',
197
- 'test/testcases/block/09_html/html_to_native/typography.text',
198
- 'test/testcases/block/09_html/parse_as_raw.text',
199
- 'test/testcases/block/09_html/simple.text',
200
- 'test/testcases/block/12_extension/comment.text',
201
- 'test/testcases/block/12_extension/ignored.text',
202
- 'test/testcases/block/12_extension/nomarkdown.text',
203
- 'test/testcases/block/13_definition_list/item_ial.text',
204
- 'test/testcases/block/13_definition_list/multiple_terms.text',
205
- 'test/testcases/block/13_definition_list/no_def_list.text',
206
- 'test/testcases/block/13_definition_list/simple.text',
207
- 'test/testcases/block/13_definition_list/with_blocks.text',
208
- 'test/testcases/block/14_table/errors.text',
209
- 'test/testcases/block/14_table/escaping.text',
210
- 'test/testcases/block/14_table/simple.text',
211
- 'test/testcases/block/15_math/normal.text',
212
- 'test/testcases/encoding.text',
213
- 'test/testcases/span/01_link/inline.text',
214
- 'test/testcases/span/01_link/link_defs.text',
215
- 'test/testcases/span/01_link/reference.text',
216
- 'test/testcases/span/02_emphasis/normal.text',
217
- 'test/testcases/span/03_codespan/normal.text',
218
- 'test/testcases/span/04_footnote/definitions.text',
219
- 'test/testcases/span/04_footnote/markers.text',
220
- 'test/testcases/span/05_html/across_lines.text',
221
- 'test/testcases/span/05_html/markdown_attr.text',
222
- 'test/testcases/span/05_html/normal.text',
223
- 'test/testcases/span/autolinks/url_links.text',
224
- 'test/testcases/span/extension/comment.text',
225
- 'test/testcases/span/ial/simple.text',
226
- 'test/testcases/span/line_breaks/normal.text',
227
- 'test/testcases/span/text_substitutions/entities_as_char.text',
228
- 'test/testcases/span/text_substitutions/entities.text',
229
- 'test/testcases/span/text_substitutions/typography.text'
230
- ]
197
+ 'test/testcases/block/03_paragraph/no_newline_at_end.text',
198
+ 'test/testcases/block/03_paragraph/indented.text',
199
+ 'test/testcases/block/03_paragraph/two_para.text',
200
+ 'test/testcases/block/04_header/atx_header.text',
201
+ 'test/testcases/block/04_header/setext_header.text',
202
+ 'test/testcases/block/05_blockquote/indented.text',
203
+ 'test/testcases/block/05_blockquote/lazy.text',
204
+ 'test/testcases/block/05_blockquote/nested.text',
205
+ 'test/testcases/block/05_blockquote/no_newline_at_end.text',
206
+ 'test/testcases/block/06_codeblock/error.text',
207
+ 'test/testcases/block/07_horizontal_rule/error.text',
208
+ 'test/testcases/block/08_list/escaping.text',
209
+ 'test/testcases/block/08_list/item_ial.text',
210
+ 'test/testcases/block/08_list/lazy.text',
211
+ 'test/testcases/block/08_list/list_and_others.text',
212
+ 'test/testcases/block/08_list/other_first_element.text',
213
+ 'test/testcases/block/08_list/simple_ul.text',
214
+ 'test/testcases/block/08_list/special_cases.text',
215
+ 'test/testcases/block/09_html/comment.text',
216
+ 'test/testcases/block/09_html/html_to_native/code.text',
217
+ 'test/testcases/block/09_html/html_to_native/emphasis.text',
218
+ 'test/testcases/block/09_html/html_to_native/typography.text',
219
+ 'test/testcases/block/09_html/parse_as_raw.text',
220
+ 'test/testcases/block/09_html/simple.text',
221
+ 'test/testcases/block/12_extension/comment.text',
222
+ 'test/testcases/block/12_extension/ignored.text',
223
+ 'test/testcases/block/12_extension/nomarkdown.text',
224
+ 'test/testcases/block/13_definition_list/item_ial.text',
225
+ 'test/testcases/block/13_definition_list/multiple_terms.text',
226
+ 'test/testcases/block/13_definition_list/no_def_list.text',
227
+ 'test/testcases/block/13_definition_list/simple.text',
228
+ 'test/testcases/block/13_definition_list/with_blocks.text',
229
+ 'test/testcases/block/14_table/errors.text',
230
+ 'test/testcases/block/14_table/escaping.text',
231
+ 'test/testcases/block/14_table/simple.text',
232
+ 'test/testcases/block/15_math/normal.text',
233
+ 'test/testcases/encoding.text',
234
+ 'test/testcases/span/01_link/inline.text',
235
+ 'test/testcases/span/01_link/link_defs.text',
236
+ 'test/testcases/span/01_link/reference.text',
237
+ 'test/testcases/span/02_emphasis/normal.text',
238
+ 'test/testcases/span/03_codespan/normal.text',
239
+ 'test/testcases/span/04_footnote/definitions.text',
240
+ 'test/testcases/span/04_footnote/markers.text',
241
+ 'test/testcases/span/05_html/across_lines.text',
242
+ 'test/testcases/span/05_html/markdown_attr.text',
243
+ 'test/testcases/span/05_html/normal.text',
244
+ 'test/testcases/span/05_html/raw_span_elements.text',
245
+ 'test/testcases/span/autolinks/url_links.text',
246
+ 'test/testcases/span/extension/comment.text',
247
+ 'test/testcases/span/ial/simple.text',
248
+ 'test/testcases/span/line_breaks/normal.text',
249
+ 'test/testcases/span/text_substitutions/entities_as_char.text',
250
+ 'test/testcases/span/text_substitutions/entities.text',
251
+ 'test/testcases/span/text_substitutions/typography.text',
252
+ ('test/testcases/span/03_codespan/highlighting-rouge.text' if RUBY_VERSION < '2.0'),
253
+ ('test/testcases/block/06_codeblock/highlighting-rouge.text' if RUBY_VERSION < '2.0'), #bc of rouge
254
+ ]
231
255
 
232
256
  # Generate test methods for gfm-to-html conversion
233
257
  Dir[File.dirname(__FILE__) + '/{testcases,testcases_gfm}/**/*.text'].each do |text_file|
@@ -252,7 +276,7 @@ class TestFiles < Minitest::Test
252
276
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
253
277
  opts_file = text_file.sub(/\.text$/, '.options')
254
278
  options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
255
- (Kramdown::Converter.constants.map {|c| c.to_sym} - [:Base, :RemoveHtmlTags]).each do |conv_class|
279
+ (Kramdown::Converter.constants.map {|c| c.to_sym} - [:Base, :RemoveHtmlTags, :MathEngine, :SyntaxHighlighter]).each do |conv_class|
256
280
  next if conv_class == :Pdf && RUBY_VERSION < '1.9'
257
281
  define_method("test_whether_#{conv_class}_modifies_tree_with_file_#{text_file.tr('.', '_')}") do
258
282
  doc = Kramdown::Document.new(File.read(text_file), options)