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.
- checksums.yaml +4 -4
- data/CONTRIBUTERS +1 -1
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/doc/default.template +2 -2
- data/doc/index.page +2 -2
- data/doc/installation.page +2 -2
- data/lib/kramdown.rb +1 -1
- data/lib/kramdown/compatibility.rb +1 -1
- data/lib/kramdown/converter.rb +1 -1
- data/lib/kramdown/converter/base.rb +1 -1
- data/lib/kramdown/converter/hash_ast.rb +1 -1
- data/lib/kramdown/converter/html.rb +12 -9
- data/lib/kramdown/converter/kramdown.rb +1 -1
- data/lib/kramdown/converter/latex.rb +1 -1
- data/lib/kramdown/converter/math_engine/itex2mml.rb +1 -1
- data/lib/kramdown/converter/math_engine/mathjax.rb +1 -1
- data/lib/kramdown/converter/math_engine/mathjaxnode.rb +1 -1
- data/lib/kramdown/converter/math_engine/ritex.rb +1 -1
- data/lib/kramdown/converter/pdf.rb +1 -1
- data/lib/kramdown/converter/remove_html_tags.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter.rb +4 -1
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +4 -4
- data/lib/kramdown/converter/syntax_highlighter/minted.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +3 -2
- data/lib/kramdown/converter/toc.rb +1 -1
- data/lib/kramdown/document.rb +1 -1
- data/lib/kramdown/element.rb +1 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +1 -1
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/parser/base.rb +1 -1
- data/lib/kramdown/parser/gfm.rb +2 -2
- data/lib/kramdown/parser/html.rb +18 -7
- data/lib/kramdown/parser/kramdown.rb +1 -1
- data/lib/kramdown/parser/kramdown/abbreviation.rb +1 -1
- data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
- data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
- data/lib/kramdown/parser/kramdown/block_boundary.rb +1 -1
- data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
- data/lib/kramdown/parser/kramdown/codeblock.rb +1 -1
- data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
- data/lib/kramdown/parser/kramdown/emphasis.rb +2 -2
- data/lib/kramdown/parser/kramdown/eob.rb +1 -1
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
- data/lib/kramdown/parser/kramdown/extensions.rb +1 -1
- data/lib/kramdown/parser/kramdown/footnote.rb +1 -1
- data/lib/kramdown/parser/kramdown/header.rb +1 -1
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
- data/lib/kramdown/parser/kramdown/html.rb +6 -4
- data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
- data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +1 -1
- data/lib/kramdown/parser/kramdown/list.rb +1 -1
- data/lib/kramdown/parser/kramdown/math.rb +1 -1
- data/lib/kramdown/parser/kramdown/paragraph.rb +1 -1
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
- data/lib/kramdown/parser/kramdown/table.rb +1 -1
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
- data/lib/kramdown/parser/markdown.rb +1 -1
- data/lib/kramdown/utils.rb +1 -1
- data/lib/kramdown/utils/configurable.rb +1 -1
- data/lib/kramdown/utils/entities.rb +1 -1
- data/lib/kramdown/utils/html.rb +1 -1
- data/lib/kramdown/utils/ordered_hash.rb +1 -1
- data/lib/kramdown/utils/string_scanner.rb +1 -1
- data/lib/kramdown/utils/unidecoder.rb +1 -1
- data/lib/kramdown/version.rb +2 -2
- data/test/run_tests.rb +1 -1
- data/test/test_files.rb +7 -1
- data/test/test_location.rb +1 -1
- data/test/test_string_scanner_kramdown.rb +1 -1
- data/test/testcases/block/06_codeblock/highlighting-opts.html +2 -2
- data/test/testcases/block/06_codeblock/highlighting.html +2 -2
- data/test/testcases/block/06_codeblock/rouge/simple.html +3 -3
- data/test/testcases/block/09_html/not_parsed.html +1 -1
- data/test/testcases/block/09_html/simple.html +0 -4
- data/test/testcases/block/09_html/simple.html.19 +0 -4
- data/test/testcases/block/09_html/simple.text +1 -5
- data/test/testcases/block/09_html/xml.html +8 -0
- data/test/testcases/block/09_html/xml.text +7 -0
- data/test/testcases/block/12_extension/options3.html +2 -2
- data/test/testcases/span/02_emphasis/normal.html +2 -0
- data/test/testcases/span/02_emphasis/normal.text +2 -0
- data/test/testcases/span/05_html/xml.html +5 -0
- data/test/testcases/span/05_html/xml.text +5 -0
- data/test/testcases_gfm/backticks_syntax.html +2 -2
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04412c06b375292d49a6a3667d1becaa48a8878a
|
4
|
+
data.tar.gz: 52bffae17bc547b1666beb23154ab2d4a452d076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5aa8a34e1fd82af97c2791e302311f7dfd700306604e9be6eae06a34c2e260e54e5fb96bf7ca5911b01c579ec4349dc96dcde2244b2c830d390198626b4ac9f
|
7
|
+
data.tar.gz: 4e675fda53fb2b709f1387a51ffb90cb3d8fb137ac71423f8a82fd0cd94c29c84aff00274c2d4aabd7922170ecdda161b4e549441699f2c76ecd317d20663128
|
data/CONTRIBUTERS
CHANGED
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-
|
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.
|
1
|
+
1.11.0
|
data/doc/default.template
CHANGED
@@ -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-
|
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-
|
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
|
|
data/doc/index.page
CHANGED
@@ -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.
|
101
|
-
**2016-
|
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>
|
data/doc/installation.page
CHANGED
@@ -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.
|
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.
|
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
|
|
data/lib/kramdown.rb
CHANGED
data/lib/kramdown/converter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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-
|
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-
|
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,
|
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
|
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-
|
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,
|
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
|
|
data/lib/kramdown/document.rb
CHANGED
data/lib/kramdown/element.rb
CHANGED
data/lib/kramdown/error.rb
CHANGED
data/lib/kramdown/options.rb
CHANGED
data/lib/kramdown/parser.rb
CHANGED
data/lib/kramdown/parser/base.rb
CHANGED
data/lib/kramdown/parser/gfm.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
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
|
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 = /~~/
|
data/lib/kramdown/parser/html.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
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]
|
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
|
-
|
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
|
-
|
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)
|