kramdown 1.10.0 → 1.11.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +1 -1
  3. data/Rakefile +2 -1
  4. data/VERSION +1 -1
  5. data/doc/default.template +2 -2
  6. data/doc/index.page +2 -2
  7. data/doc/installation.page +2 -2
  8. data/lib/kramdown.rb +1 -1
  9. data/lib/kramdown/compatibility.rb +1 -1
  10. data/lib/kramdown/converter.rb +1 -1
  11. data/lib/kramdown/converter/base.rb +1 -1
  12. data/lib/kramdown/converter/hash_ast.rb +1 -1
  13. data/lib/kramdown/converter/html.rb +12 -9
  14. data/lib/kramdown/converter/kramdown.rb +1 -1
  15. data/lib/kramdown/converter/latex.rb +1 -1
  16. data/lib/kramdown/converter/math_engine/itex2mml.rb +1 -1
  17. data/lib/kramdown/converter/math_engine/mathjax.rb +1 -1
  18. data/lib/kramdown/converter/math_engine/mathjaxnode.rb +1 -1
  19. data/lib/kramdown/converter/math_engine/ritex.rb +1 -1
  20. data/lib/kramdown/converter/pdf.rb +1 -1
  21. data/lib/kramdown/converter/remove_html_tags.rb +1 -1
  22. data/lib/kramdown/converter/syntax_highlighter.rb +4 -1
  23. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +4 -4
  24. data/lib/kramdown/converter/syntax_highlighter/minted.rb +1 -1
  25. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +3 -2
  26. data/lib/kramdown/converter/toc.rb +1 -1
  27. data/lib/kramdown/document.rb +1 -1
  28. data/lib/kramdown/element.rb +1 -1
  29. data/lib/kramdown/error.rb +1 -1
  30. data/lib/kramdown/options.rb +1 -1
  31. data/lib/kramdown/parser.rb +1 -1
  32. data/lib/kramdown/parser/base.rb +1 -1
  33. data/lib/kramdown/parser/gfm.rb +2 -2
  34. data/lib/kramdown/parser/html.rb +18 -7
  35. data/lib/kramdown/parser/kramdown.rb +1 -1
  36. data/lib/kramdown/parser/kramdown/abbreviation.rb +1 -1
  37. data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
  38. data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
  39. data/lib/kramdown/parser/kramdown/block_boundary.rb +1 -1
  40. data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
  41. data/lib/kramdown/parser/kramdown/codeblock.rb +1 -1
  42. data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
  43. data/lib/kramdown/parser/kramdown/emphasis.rb +2 -2
  44. data/lib/kramdown/parser/kramdown/eob.rb +1 -1
  45. data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
  46. data/lib/kramdown/parser/kramdown/extensions.rb +1 -1
  47. data/lib/kramdown/parser/kramdown/footnote.rb +1 -1
  48. data/lib/kramdown/parser/kramdown/header.rb +1 -1
  49. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
  50. data/lib/kramdown/parser/kramdown/html.rb +6 -4
  51. data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
  52. data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
  53. data/lib/kramdown/parser/kramdown/link.rb +1 -1
  54. data/lib/kramdown/parser/kramdown/list.rb +1 -1
  55. data/lib/kramdown/parser/kramdown/math.rb +1 -1
  56. data/lib/kramdown/parser/kramdown/paragraph.rb +1 -1
  57. data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
  58. data/lib/kramdown/parser/kramdown/table.rb +1 -1
  59. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
  60. data/lib/kramdown/parser/markdown.rb +1 -1
  61. data/lib/kramdown/utils.rb +1 -1
  62. data/lib/kramdown/utils/configurable.rb +1 -1
  63. data/lib/kramdown/utils/entities.rb +1 -1
  64. data/lib/kramdown/utils/html.rb +1 -1
  65. data/lib/kramdown/utils/ordered_hash.rb +1 -1
  66. data/lib/kramdown/utils/string_scanner.rb +1 -1
  67. data/lib/kramdown/utils/unidecoder.rb +1 -1
  68. data/lib/kramdown/version.rb +2 -2
  69. data/test/run_tests.rb +1 -1
  70. data/test/test_files.rb +7 -1
  71. data/test/test_location.rb +1 -1
  72. data/test/test_string_scanner_kramdown.rb +1 -1
  73. data/test/testcases/block/06_codeblock/highlighting-opts.html +2 -2
  74. data/test/testcases/block/06_codeblock/highlighting.html +2 -2
  75. data/test/testcases/block/06_codeblock/rouge/simple.html +3 -3
  76. data/test/testcases/block/09_html/not_parsed.html +1 -1
  77. data/test/testcases/block/09_html/simple.html +0 -4
  78. data/test/testcases/block/09_html/simple.html.19 +0 -4
  79. data/test/testcases/block/09_html/simple.text +1 -5
  80. data/test/testcases/block/09_html/xml.html +8 -0
  81. data/test/testcases/block/09_html/xml.text +7 -0
  82. data/test/testcases/block/12_extension/options3.html +2 -2
  83. data/test/testcases/span/02_emphasis/normal.html +2 -0
  84. data/test/testcases/span/02_emphasis/normal.text +2 -0
  85. data/test/testcases/span/05_html/xml.html +5 -0
  86. data/test/testcases/span/05_html/xml.text +5 -0
  87. data/test/testcases_gfm/backticks_syntax.html +2 -2
  88. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b6f2cf839ac06d2599c5b3b973045b114086f82
4
- data.tar.gz: 0cf9626a31156f2e2c7d993041953ffa9c33f04e
3
+ metadata.gz: 04412c06b375292d49a6a3667d1becaa48a8878a
4
+ data.tar.gz: 52bffae17bc547b1666beb23154ab2d4a452d076
5
5
  SHA512:
6
- metadata.gz: d62ca19bbaaa0a42dcd61042782f0e18a1591c136948e9495e8ec193f1f5ddac3ec1f2916196c8d2c1e094ad3a3057be2a8d660072bad4cbf98f1ad75e2e7048
7
- data.tar.gz: fa8218c25f56a99b9f749cb6da57f44794394ce623a20ac8aa26a858cb8a08c26f1caac0dcabaf6367846980a81b47cd2158cbe84b79631c49c29a62885c80c1
6
+ metadata.gz: f5aa8a34e1fd82af97c2791e302311f7dfd700306604e9be6eae06a34c2e260e54e5fb96bf7ca5911b01c579ec4349dc96dcde2244b2c830d390198626b4ac9f
7
+ data.tar.gz: 4e675fda53fb2b709f1387a51ffb90cb3d8fb137ac71423f8a82fd0cd94c29c84aff00274c2d4aabd7922170ecdda161b4e549441699f2c76ecd317d20663128
@@ -1,6 +1,6 @@
1
1
  Count Name
2
2
  ======= ====
3
- 789 Thomas Leitner <t_leitner@gmx.at>
3
+ 800 Thomas Leitner <t_leitner@gmx.at>
4
4
  6 Gioele Barabucci <gioele@svario.it>
5
5
  4 Ted Pak <powerpak006@gmail.com>
6
6
  4 Arne Brasseur <arne@arnebrasseur.net>
data/Rakefile CHANGED
@@ -180,6 +180,7 @@ EOF
180
180
  s.add_development_dependency 'rouge', '~> 1.8'
181
181
  s.add_development_dependency 'stringex', '~> 1.5.1'
182
182
  s.add_development_dependency 'prawn', '~> 2.0'
183
+ s.add_development_dependency 'prawn-table', '~> 0.2.2'
183
184
  s.add_development_dependency 'ritex', '~> 1.0'
184
185
  s.add_development_dependency 'itextomml', '~> 1.5'
185
186
 
@@ -239,7 +240,7 @@ EOF
239
240
  COPYRIGHT=<<EOF
240
241
  #
241
242
  #--
242
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
243
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
243
244
  #
244
245
  # This file is part of kramdown which is licensed under the MIT.
245
246
  #++
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.0
1
+ 1.11.0
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
5
  <meta name="author" content="Thomas Leitner" />
6
- <meta name="copyright" content="2009-2015 Thomas Leitner" />
6
+ <meta name="copyright" content="2009-2016 Thomas Leitner" />
7
7
  <meta name="description" content="kramdown is a fast, pure-Ruby Markdown-superset converter" />
8
8
  <meta name="keywords" content="ruby, kramdown, markdown, text markup" />
9
9
  <link href="{relocatable: default.css}" type="text/css" rel="stylesheet" media="screen,projection" />
@@ -43,7 +43,7 @@
43
43
  </div>
44
44
 
45
45
  <footer>
46
- <div class="float-left">Copyright © 2009-2015 Thomas Leitner</div>
46
+ <div class="float-left">Copyright © 2009-2016 Thomas Leitner</div>
47
47
  <div class="float-right">Generated by <a href="http://webgen.gettalong.org">webgen</a></div>
48
48
  </footer>
49
49
 
@@ -97,8 +97,8 @@ extensions that have been made popular by the [PHP Markdown Extra] package and [
97
97
  It is probably the fastest pure-Ruby Markdown converter available (September 2014), being about 3x
98
98
  faster than [Maruku] and about 4.5x faster than [BlueFeather].
99
99
 
100
- Version **1.10.0**{:itemprop="softwareVersion"} released on
101
- **2016-03-02**{:itemprop="datePublished"}, [more news](news.html)
100
+ Version **1.11.0**{:itemprop="softwareVersion"} released on
101
+ **2016-05-01**{:itemprop="datePublished"}, [more news](news.html)
102
102
  {: style="text-align: center; font-size: 80%"}
103
103
 
104
104
  </div>
@@ -8,7 +8,7 @@ sort_info: 5
8
8
  ## Dependencies
9
9
 
10
10
  Since kramdown is written in Ruby, you just need the [Ruby interpreter](http://www.ruby-lang.org),
11
- version 1.8.5, 1.8.6, 1.8.7, 1.9.2, 1.9.3 or 2.0.0. There are no other dependencies.
11
+ version 1.8.5, 1.8.6, 1.8.7, 1.9.2, 1.9.3 or 2.x. There are no other dependencies.
12
12
 
13
13
 
14
14
  ## Compatibility Notes
@@ -16,7 +16,7 @@ version 1.8.5, 1.8.6, 1.8.7, 1.9.2, 1.9.3 or 2.0.0. There are no other dependenc
16
16
  kramdown should work on any platform which supports Ruby. It has been successfully tested on the
17
17
  following platforms:
18
18
 
19
- * Linux with Ruby 1.8.5, 1.8.6, 1.8.7, 1.9.2, 1.9.3, 2.0.0 and jruby 1.7.3.
19
+ * Linux with Ruby 1.8.7, 1.9.3, 2.x, jruby 1.7.19 and jruby 9.0.0.0.
20
20
 
21
21
  See the platform specific installation notes for more information!
22
22
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -92,11 +92,11 @@ module Kramdown
92
92
  def convert_codeblock(el, indent)
93
93
  attr = el.attr.dup
94
94
  lang = extract_code_language!(attr)
95
- lang = el.options[:lang] if el.options.has_key?(:lang)
96
- highlighted_code = highlight_code(el.value, lang, :block)
95
+ hl_opts = {}
96
+ highlighted_code = highlight_code(el.value, el.options[:lang] || lang, :block, hl_opts)
97
97
 
98
98
  if highlighted_code
99
- add_syntax_highlighter_to_class_attr(attr)
99
+ add_syntax_highlighter_to_class_attr(attr, lang || hl_opts[:default_lang])
100
100
  "#{' '*indent}<div#{html_attributes(attr)}>#{highlighted_code}#{' '*indent}</div>\n"
101
101
  else
102
102
  result = escape_html(el.value)
@@ -113,7 +113,7 @@ module Kramdown
113
113
  end
114
114
  end
115
115
  code_attr = {}
116
- code_attr['class'] = "language-#{lang.sub(/\?.*$/, '')}" if lang
116
+ code_attr['class'] = "language-#{lang}" if lang
117
117
  "#{' '*indent}<pre#{html_attributes(attr)}><code#{html_attributes(code_attr)}>#{result}\n</code></pre>\n"
118
118
  end
119
119
  end
@@ -253,9 +253,10 @@ module Kramdown
253
253
  def convert_codespan(el, indent)
254
254
  attr = el.attr.dup
255
255
  lang = extract_code_language(attr)
256
- result = highlight_code(el.value, lang, :span)
256
+ hl_opts = {}
257
+ result = highlight_code(el.value, lang, :span, hl_opts)
257
258
  if result
258
- add_syntax_highlighter_to_class_attr(attr)
259
+ add_syntax_highlighter_to_class_attr(attr, hl_opts[:default_lang])
259
260
  else
260
261
  result = escape_html(el.value)
261
262
  end
@@ -363,9 +364,11 @@ module Kramdown
363
364
  "#{' '*indent}<#{name}#{html_attributes(attr)}>\n#{body}#{' '*indent}</#{name}>\n"
364
365
  end
365
366
 
366
- # Add the syntax highlighter name to the 'class' attribute of the given attribute hash.
367
- def add_syntax_highlighter_to_class_attr(attr)
367
+ # Add the syntax highlighter name to the 'class' attribute of the given attribute hash. And
368
+ # overwrites or add a "language-LANG" part using the +lang+ parameter if +lang+ is not nil.
369
+ def add_syntax_highlighter_to_class_attr(attr, lang = nil)
368
370
  (attr['class'] = (attr['class'] || '') + " highlighter-#{@options[:syntax_highlighter]}").lstrip!
371
+ attr['class'].sub!(/\blanguage-\S+|(^)/) { "language-#{lang}#{$1 ? ' ' : ''}" } if lang
369
372
  end
370
373
 
371
374
  # Generate and return an element tree for the table of contents.
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -46,6 +46,9 @@ module Kramdown
46
46
  # :block type text correctly wrapped (i.e. normally inside a pre-tag, but may
47
47
  # also be a table-tag or just a div-tag) but :span type text *without* a
48
48
  # code-tag!
49
+ #
50
+ # Also, a syntax highlighter should store the default highlighting language for
51
+ # the invocation in the +opts+ hash under the key :default_lang.
49
52
  module SyntaxHighlighter
50
53
  end
51
54
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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,14 +21,14 @@ module Kramdown::Converter::SyntaxHighlighter
21
21
  AVAILABLE = false # :nodoc:
22
22
  end
23
23
 
24
- def self.call(converter, text, lang, type, _unused_opts)
24
+ def self.call(converter, text, lang, type, call_opts)
25
25
  return nil unless converter.options[:enable_coderay]
26
26
 
27
27
  if type == :span && lang
28
28
  ::CodeRay.scan(text, lang.to_sym).html(options(converter, :span)).chomp
29
29
  elsif type == :block && (lang || options(converter, :default_lang))
30
- lang = (lang || options(converter, :default_lang)).to_s.gsub(/-/, '_').to_sym
31
- ::CodeRay.scan(text, lang).html(options(converter, :block)).chomp << "\n"
30
+ lang ||= call_opts[:default_lang] = options(converter, :default_lang)
31
+ ::CodeRay.scan(text, lang.to_s.gsub(/-/, '_').to_sym).html(options(converter, :block)).chomp << "\n"
32
32
  else
33
33
  nil
34
34
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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,8 +21,9 @@ module Kramdown::Converter::SyntaxHighlighter
21
21
  AVAILABLE = false # :nodoc:
22
22
  end
23
23
 
24
- def self.call(converter, text, lang, type, _unused_opts)
24
+ def self.call(converter, text, lang, type, call_opts)
25
25
  opts = options(converter, type)
26
+ call_opts[:default_lang] = opts[:default_lang]
26
27
  lexer = ::Rouge::Lexer.find_fancy(lang || opts[:default_lang], text)
27
28
  return nil if opts[:disable] || !lexer
28
29
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -61,7 +61,7 @@ module Kramdown
61
61
  ATX_HEADER_START = /^\#{1,6}\s/
62
62
  define_parser(:atx_header_gfm, ATX_HEADER_START, nil, 'parse_atx_header')
63
63
 
64
- FENCED_CODEBLOCK_MATCH = /^(([~`]){3,})\s*?((\S+)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m
64
+ FENCED_CODEBLOCK_MATCH = /^(([~`]){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m
65
65
  define_parser(:codeblock_fenced_gfm, /^[~`]{3,}/, nil, 'parse_codeblock_fenced')
66
66
 
67
67
  STRIKETHROUGH_DELIM = /~~/
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -59,6 +59,12 @@ module Kramdown
59
59
  figcaption footer form h1 h2 h3 h4 h5 h6 header hgroup hr html head iframe legend menu
60
60
  li map nav ol optgroup p pre section summary table tbody td th thead tfoot tr ul}
61
61
  HTML_ELEMENTS_WITHOUT_BODY = %w{area base br col command embed hr img input keygen link meta param source track wbr}
62
+
63
+ HTML_ELEMENT = Hash.new(false)
64
+ (HTML_SPAN_ELEMENTS + HTML_BLOCK_ELEMENTS + HTML_ELEMENTS_WITHOUT_BODY +
65
+ HTML_CONTENT_MODEL.keys).each do |a|
66
+ HTML_ELEMENT[a] = true
67
+ end
62
68
  end
63
69
 
64
70
 
@@ -77,9 +83,10 @@ module Kramdown
77
83
  # element is already closed, ie. contains no body; the third parameter specifies whether the
78
84
  # body - and the end tag - need to be handled in case closed=false).
79
85
  def handle_html_start_tag(line = nil) # :yields: el, closed, handle_body
80
- name = @src[1].downcase
86
+ name = @src[1]
87
+ name.downcase! if HTML_ELEMENT[name.downcase]
81
88
  closed = !@src[4].nil?
82
- attrs = parse_html_attributes(@src[2], line)
89
+ attrs = parse_html_attributes(@src[2], line, HTML_ELEMENT[name])
83
90
 
84
91
  el = Element.new(:html_element, name, attrs, :category => :block)
85
92
  el.options[:location] = line if line
@@ -99,10 +106,13 @@ module Kramdown
99
106
  # Parses the given string for HTML attributes and returns the resulting hash.
100
107
  #
101
108
  # If the optional +line+ parameter is supplied, it is used in warning messages.
102
- def parse_html_attributes(str, line = nil)
109
+ #
110
+ # If the optional +in_html_tag+ parameter is set to +false+, attributes are not modified to
111
+ # contain only lowercase letters.
112
+ def parse_html_attributes(str, line = nil, in_html_tag = true)
103
113
  attrs = Utils::OrderedHash.new
104
114
  str.scan(HTML_ATTRIBUTE_RE).each do |attr, sep, val|
105
- attr.downcase!
115
+ attr.downcase! if in_html_tag
106
116
  if attrs.has_key?(attr)
107
117
  warning("Duplicate HTML attribute '#{attr}' on line #{line || '?'} - overwriting previous one")
108
118
  end
@@ -155,10 +165,11 @@ module Kramdown
155
165
  handle_html_start_tag(&block) # DEPRECATED: method needs to accept line number in 2.0
156
166
  end
157
167
  elsif @src.scan(HTML_TAG_CLOSE_RE)
158
- if @tree.value == @src[1].downcase
168
+ if @tree.value == (HTML_ELEMENT[@tree.value] ? @src[1].downcase : @src[1])
159
169
  done = true
160
170
  else
161
- warning("Found invalidly used HTML closing tag for '#{@src[1].downcase}' on line #{line} - ignoring it")
171
+ add_text(@src.matched, @tree, :text)
172
+ warning("Found invalidly used HTML closing tag for '#{@src[1]}' on line #{line} - ignoring it")
162
173
  end
163
174
  else
164
175
  add_text(@src.getch, @tree, :text)