kramdown 1.5.0 → 1.6.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 +3 -1
- data/README.md +6 -6
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/kramdown +1 -1
- data/doc/default.template +2 -2
- data/doc/index.page +21 -7
- data/doc/options.page +42 -3
- data/doc/sidebar.template +0 -7
- data/doc/sitemap.sitemap +5 -0
- data/doc/syntax.page +31 -3
- data/doc/virtual +3 -0
- 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 +2 -1
- data/lib/kramdown/converter/html.rb +10 -5
- data/lib/kramdown/converter/kramdown.rb +13 -7
- data/lib/kramdown/converter/latex.rb +2 -1
- data/lib/kramdown/converter/math_engine/itex2mml.rb +1 -1
- data/lib/kramdown/converter/math_engine/mathjax.rb +18 -3
- data/lib/kramdown/converter/math_engine/ritex.rb +1 -1
- data/lib/kramdown/converter/pdf.rb +3 -2
- data/lib/kramdown/converter/remove_html_tags.rb +3 -1
- data/lib/kramdown/converter/syntax_highlighter.rb +53 -0
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +2 -2
- data/lib/kramdown/converter/toc.rb +2 -2
- data/lib/kramdown/document.rb +5 -5
- data/lib/kramdown/element.rb +4 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +4 -3
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/parser/base.rb +8 -4
- data/lib/kramdown/parser/gfm.rb +9 -1
- data/lib/kramdown/parser/html.rb +18 -3
- data/lib/kramdown/parser/kramdown.rb +8 -5
- data/lib/kramdown/parser/kramdown/abbreviation.rb +10 -2
- 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 +8 -7
- data/lib/kramdown/parser/kramdown/footnote.rb +11 -4
- 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 +7 -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 +8 -5
- data/lib/kramdown/parser/kramdown/list.rb +12 -7
- data/lib/kramdown/parser/kramdown/math.rb +3 -3
- data/lib/kramdown/parser/kramdown/paragraph.rb +3 -3
- 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 +2 -2
- 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 +3 -1
- data/lib/kramdown/utils/ordered_hash.rb +1 -1
- data/lib/kramdown/utils/string_scanner.rb +8 -0
- data/lib/kramdown/utils/unidecoder.rb +1 -1
- data/lib/kramdown/version.rb +2 -2
- data/man/man1/kramdown.1 +1 -1
- data/test/run_tests.rb +1 -1
- data/test/test_files.rb +48 -17
- data/test/test_location.rb +8 -0
- data/test/test_string_scanner_kramdown.rb +8 -0
- data/test/testcases/block/04_header/atx_header.html +1 -1
- data/test/testcases/block/06_codeblock/highlighting-rouge.html +2 -2
- data/test/testcases/block/09_html/html_after_block.html +7 -0
- data/test/testcases/block/09_html/html_after_block.text +5 -0
- data/test/testcases/block/11_ial/simple.html +3 -1
- data/test/testcases/block/11_ial/simple.text +5 -1
- data/test/testcases/block/15_math/gh_128.html +1 -1
- data/test/testcases/block/15_math/mathjax_preview.html +4 -0
- data/test/testcases/block/15_math/mathjax_preview.options +2 -0
- data/test/testcases/block/15_math/mathjax_preview.text +5 -0
- data/test/testcases/block/15_math/mathjax_preview_simple.html +4 -0
- data/test/testcases/block/15_math/mathjax_preview_simple.options +2 -0
- data/test/testcases/block/15_math/mathjax_preview_simple.text +5 -0
- data/test/testcases/block/15_math/normal.html +1 -1
- data/test/testcases/block/16_toc/toc_exclude.html +7 -7
- data/test/testcases/block/16_toc/toc_levels.html +4 -4
- data/test/testcases/block/16_toc/toc_with_footnotes.html +1 -1
- data/test/testcases/span/01_link/empty_title.htmlinput +3 -0
- data/test/testcases/span/01_link/empty_title.text +7 -0
- data/test/testcases/span/01_link/link_defs_with_ial.html +4 -0
- data/test/testcases/span/01_link/link_defs_with_ial.text +16 -0
- data/test/testcases/span/02_emphasis/normal.html +2 -0
- data/test/testcases/span/02_emphasis/normal.text +2 -0
- data/test/testcases/span/04_footnote/markers.text +1 -0
- data/test/testcases/span/abbreviations/abbrev.html +3 -1
- data/test/testcases/span/abbreviations/abbrev.text +7 -0
- data/test/testcases/span/line_breaks/normal.html +2 -2
- data/test/testcases/span/line_breaks/normal.latex +2 -2
- metadata +20 -6
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 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
|
-
require 'kramdown/parser
|
10
|
+
require 'kramdown/parser'
|
11
11
|
|
12
12
|
module Kramdown
|
13
13
|
|
data/lib/kramdown/utils.rb
CHANGED
data/lib/kramdown/utils/html.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 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
|
+
require 'rexml/parsers/baseparser'
|
11
|
+
|
10
12
|
module Kramdown
|
11
13
|
|
12
14
|
module Utils
|
data/lib/kramdown/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 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.
|
13
|
+
VERSION = '1.6.0'
|
14
14
|
|
15
15
|
end
|
data/man/man1/kramdown.1
CHANGED
data/test/run_tests.rb
CHANGED
data/test/test_files.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -41,10 +41,10 @@ class TestFiles < Minitest::Test
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
# Generate test methods for html-to-html conversion
|
44
|
+
# Generate test methods for html-to-{html,kramdown} conversion
|
45
45
|
`tidy -v 2>&1`
|
46
46
|
if $?.exitstatus != 0
|
47
|
-
warn("Skipping html-to-html tests because tidy executable is missing")
|
47
|
+
warn("Skipping html-to-{html,kramdown} tests because tidy executable is missing")
|
48
48
|
else
|
49
49
|
EXCLUDE_HTML_FILES = ['test/testcases/block/06_codeblock/whitespace.html', # bc of span inside pre
|
50
50
|
'test/testcases/block/09_html/simple.html', # bc of xml elements
|
@@ -57,18 +57,34 @@ class TestFiles < Minitest::Test
|
|
57
57
|
'test/testcases/span/math/ritex.html', # bc of tidy
|
58
58
|
'test/testcases/block/15_math/itex2mml.html', # bc of tidy
|
59
59
|
'test/testcases/span/math/itex2mml.html', # bc of tidy
|
60
|
-
|
60
|
+
'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
|
61
|
+
'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
|
62
|
+
].compact
|
63
|
+
EXCLUDE_HTML_TEXT_FILES = ['test/testcases/block/09_html/parse_as_span.htmlinput',
|
64
|
+
'test/testcases/block/09_html/parse_as_raw.htmlinput',
|
65
|
+
].compact
|
61
66
|
Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,html.19,htmlinput,htmlinput.19}'].each do |html_file|
|
62
67
|
next if EXCLUDE_HTML_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
|
63
68
|
next if (RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')) ||
|
64
69
|
(RUBY_VERSION < '1.9' && html_file =~ /\.19$/)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
out_files = []
|
72
|
+
out_files << [(html_file =~ /\.htmlinput(\.19)?$/ ? html_file.sub(/input(\.19)?$/, '') : html_file), :to_html]
|
73
|
+
if html_file =~ /\.htmlinput(\.19)?$/ && !EXCLUDE_HTML_TEXT_FILES.any? {|f| html_file =~ /#{f}/}
|
74
|
+
out_files << [html_file.sub(/htmlinput(\.19)?$/, 'text'), :to_kramdown]
|
75
|
+
end
|
76
|
+
out_files.select {|f, _| File.exist?(f)}.each do |out_file, out_method|
|
77
|
+
define_method('test_' + html_file.tr('.', '_') + "_to_#{File.extname(out_file)}") do
|
78
|
+
opts_file = html_file.sub(/\.html(input)?(\.19)?$/, '.options')
|
79
|
+
opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file)
|
80
|
+
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
|
81
|
+
doc = Kramdown::Document.new(File.read(html_file), options.merge(:input => 'html'))
|
82
|
+
if out_method == :to_html
|
83
|
+
assert_equal(tidy_output(File.read(out_file)), tidy_output(doc.send(out_method)))
|
84
|
+
else
|
85
|
+
assert_equal(File.read(out_file), doc.send(out_method))
|
86
|
+
end
|
87
|
+
end
|
72
88
|
end
|
73
89
|
end
|
74
90
|
end
|
@@ -93,8 +109,9 @@ class TestFiles < Minitest::Test
|
|
93
109
|
else
|
94
110
|
EXCLUDE_LATEX_FILES = ['test/testcases/span/01_link/image_in_a.text', # bc of image link
|
95
111
|
'test/testcases/span/01_link/imagelinks.text', # bc of image links
|
112
|
+
'test/testcases/span/01_link/empty_title.text',
|
96
113
|
'test/testcases/span/04_footnote/markers.text', # bc of footnote in header
|
97
|
-
]
|
114
|
+
].compact
|
98
115
|
Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
|
99
116
|
next if EXCLUDE_LATEX_FILES.any? {|f| text_file =~ /#{f}$/}
|
100
117
|
define_method('test_' + text_file.tr('.', '_') + "_to_latex_compilation") do
|
@@ -137,12 +154,14 @@ class TestFiles < Minitest::Test
|
|
137
154
|
'test/testcases/span/math/ritex.text', # bc of tidy
|
138
155
|
'test/testcases/block/15_math/itex2mml.text', # bc of tidy
|
139
156
|
'test/testcases/span/math/itex2mml.text', # bc of tidy
|
157
|
+
'test/testcases/span/01_link/link_defs_with_ial.text', # bc of attribute ordering
|
140
158
|
].compact
|
141
159
|
Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
|
142
160
|
next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/}
|
161
|
+
html_file = text_file.sub(/\.text$/, '.html')
|
162
|
+
html_file += '.19' if RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')
|
163
|
+
next unless File.exist?(html_file)
|
143
164
|
define_method('test_' + text_file.tr('.', '_') + "_to_kramdown_to_html") do
|
144
|
-
html_file = text_file.sub(/\.text$/, '.html')
|
145
|
-
html_file += '.19' if RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')
|
146
165
|
opts_file = text_file.sub(/\.text$/, '.options')
|
147
166
|
opts_file = File.join(File.dirname(text_file), 'options') if !File.exist?(opts_file)
|
148
167
|
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
|
@@ -177,7 +196,10 @@ class TestFiles < Minitest::Test
|
|
177
196
|
'test/testcases/span/math/ritex.html', # bc of tidy
|
178
197
|
'test/testcases/block/15_math/itex2mml.html', # bc of tidy
|
179
198
|
'test/testcases/span/math/itex2mml.html', # bc of tidy
|
180
|
-
|
199
|
+
'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
|
200
|
+
'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
|
201
|
+
'test/testcases/span/01_link/link_defs_with_ial.html', # bc of attribute ordering
|
202
|
+
].compact
|
181
203
|
Dir[File.dirname(__FILE__) + '/testcases/**/*.{html,html.19}'].each do |html_file|
|
182
204
|
next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
|
183
205
|
next if (RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')) ||
|
@@ -251,7 +273,7 @@ class TestFiles < Minitest::Test
|
|
251
273
|
'test/testcases/span/text_substitutions/typography.text',
|
252
274
|
('test/testcases/span/03_codespan/highlighting-rouge.text' if RUBY_VERSION < '2.0'),
|
253
275
|
('test/testcases/block/06_codeblock/highlighting-rouge.text' if RUBY_VERSION < '2.0'), #bc of rouge
|
254
|
-
]
|
276
|
+
].compact
|
255
277
|
|
256
278
|
# Generate test methods for gfm-to-html conversion
|
257
279
|
Dir[File.dirname(__FILE__) + '/{testcases,testcases_gfm}/**/*.text'].each do |text_file|
|
@@ -261,6 +283,7 @@ class TestFiles < Minitest::Test
|
|
261
283
|
html_file = [(".html.19" if RUBY_VERSION >= '1.9'), ".html"].compact.
|
262
284
|
map {|ext| basename + ext }.
|
263
285
|
detect {|file| File.exist?(file) }
|
286
|
+
next unless html_file
|
264
287
|
|
265
288
|
define_method('test_gfm_' + text_file.tr('.', '_') + "_to_html") do
|
266
289
|
opts_file = basename + '.options'
|
@@ -272,12 +295,20 @@ class TestFiles < Minitest::Test
|
|
272
295
|
end
|
273
296
|
|
274
297
|
|
298
|
+
EXCLUDE_PDF_MODIFY = ['test/testcases/span/text_substitutions/entities.text',
|
299
|
+
'test/testcases/span/text_substitutions/entities_numeric.text',
|
300
|
+
'test/testcases/span/text_substitutions/entities_as_char.text',
|
301
|
+
'test/testcases/span/text_substitutions/entities_as_input.text',
|
302
|
+
'test/testcases/span/text_substitutions/entities_symbolic.text',
|
303
|
+
'test/testcases/block/04_header/with_auto_ids.text',
|
304
|
+
].compact
|
305
|
+
|
275
306
|
# Generate test methods for asserting that converters don't modify the document tree.
|
276
307
|
Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
|
277
308
|
opts_file = text_file.sub(/\.text$/, '.options')
|
278
309
|
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
|
279
310
|
(Kramdown::Converter.constants.map {|c| c.to_sym} - [:Base, :RemoveHtmlTags, :MathEngine, :SyntaxHighlighter]).each do |conv_class|
|
280
|
-
next if conv_class == :Pdf && RUBY_VERSION < '
|
311
|
+
next if conv_class == :Pdf && (RUBY_VERSION < '2.0' || EXCLUDE_PDF_MODIFY.any? {|f| text_file =~ /#{f}$/})
|
281
312
|
define_method("test_whether_#{conv_class}_modifies_tree_with_file_#{text_file.tr('.', '_')}") do
|
282
313
|
doc = Kramdown::Document.new(File.read(text_file), options)
|
283
314
|
options_before = Marshal.load(Marshal.dump(doc.options))
|
data/test/test_location.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
<div class="highlighter-rouge"><pre
|
1
|
+
<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">x</span> <span class="o">=</span> <span class="no">Class</span><span class="p">.</span><span class="nf">new</span>
|
2
2
|
</code></pre>
|
3
3
|
</div>
|
4
|
-
<div class="highlighter-rouge"><pre
|
4
|
+
<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><a></span>href<span class="nt"></a></span>
|
5
5
|
</code></pre>
|
6
6
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<p key1="val"" key2="val'" class="other-class myclass class" id="other" key="val">Some paragraph.</p>
|
1
|
+
<p key1="val"" key2="val'" class="other-class myclass class -class" id="other" key="val">Some paragraph.</p>
|
2
2
|
|
3
3
|
<p class="cls1 cls2" id="id">Some paragraph.</p>
|
4
4
|
|
@@ -20,6 +20,8 @@
|
|
20
20
|
|
21
21
|
<p class="cls">Some paragraph here</p>
|
22
22
|
|
23
|
+
<p class="cls1 cls2">Some paragraph here</p>
|
24
|
+
|
23
25
|
<p class="cls">Paragraph</p>
|
24
26
|
<p>Paragraph</p>
|
25
27
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Some paragraph.
|
2
|
-
{:.class id key="val"}
|
2
|
+
{:.class .-class id key="val"}
|
3
3
|
|
4
4
|
Some paragraph.
|
5
5
|
{:.cls1#id.cls2}
|
@@ -22,6 +22,10 @@ Some paragraph.
|
|
22
22
|
{:.cls}
|
23
23
|
Some paragraph here
|
24
24
|
|
25
|
+
{:.cls1}
|
26
|
+
{:.cls2}
|
27
|
+
Some paragraph here
|
28
|
+
|
25
29
|
Paragraph
|
26
30
|
{:.cls}
|
27
31
|
Paragraph
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<script type="math/tex; mode=display">% <![CDATA[
|
2
|
-
|
2
|
+
alert('a') alert('b<') %]]></script>
|
@@ -1,19 +1,19 @@
|
|
1
1
|
<h1 class="no_toc" id="contents">Contents</h1>
|
2
2
|
|
3
3
|
<ul id="markdown-toc">
|
4
|
-
<li><a href="#header-level-1">Header level 1</a> <ul>
|
5
|
-
<li><a href="#header-level-2">Header level 2</a> <ul>
|
6
|
-
<li><a href="#header-level-3">Header level 3</a> <ul>
|
7
|
-
<li><a href="#header-level-4">Header level 4</a></li>
|
4
|
+
<li><a href="#header-level-1" id="markdown-toc-header-level-1">Header level 1</a> <ul>
|
5
|
+
<li><a href="#header-level-2" id="markdown-toc-header-level-2">Header level 2</a> <ul>
|
6
|
+
<li><a href="#header-level-3" id="markdown-toc-header-level-3">Header level 3</a> <ul>
|
7
|
+
<li><a href="#header-level-4" id="markdown-toc-header-level-4">Header level 4</a></li>
|
8
8
|
</ul>
|
9
9
|
</li>
|
10
10
|
</ul>
|
11
11
|
</li>
|
12
12
|
</ul>
|
13
13
|
</li>
|
14
|
-
<li><a href="#other-header-level-1">Other header level 1</a> <ul>
|
15
|
-
<li><a href="#other-header-level-2">Other header level 2</a> <ul>
|
16
|
-
<li><a href="#other-header-level-3">Other header level 3</a></li>
|
14
|
+
<li><a href="#other-header-level-1" id="markdown-toc-other-header-level-1">Other header level 1</a> <ul>
|
15
|
+
<li><a href="#other-header-level-2" id="markdown-toc-other-header-level-2">Other header level 2</a> <ul>
|
16
|
+
<li><a href="#other-header-level-3" id="markdown-toc-other-header-level-3">Other header level 3</a></li>
|
17
17
|
</ul>
|
18
18
|
</li>
|
19
19
|
</ul>
|