kramdown 0.8.0 → 0.9.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.
- data/CONTRIBUTERS +2 -1
- data/ChangeLog +454 -0
- data/README +1 -1
- data/VERSION +1 -1
- data/doc/{default.less.css → default.scss.css} +12 -9
- data/doc/documentation.page +1 -1
- data/doc/index.page +37 -3
- data/doc/syntax.page +10 -7
- data/lib/kramdown/converter.rb +1 -0
- data/lib/kramdown/converter/html.rb +61 -67
- data/lib/kramdown/converter/kramdown.rb +398 -0
- data/lib/kramdown/converter/latex.rb +274 -276
- data/lib/kramdown/document.rb +2 -0
- data/lib/kramdown/options.rb +16 -15
- data/lib/kramdown/parser/base.rb +0 -1
- data/lib/kramdown/parser/html.rb +122 -27
- data/lib/kramdown/parser/kramdown.rb +2 -0
- data/lib/kramdown/parser/kramdown/attribute_list.rb +2 -0
- data/lib/kramdown/parser/kramdown/extension.rb +2 -1
- data/lib/kramdown/parser/kramdown/html.rb +2 -2
- data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +5 -2
- data/lib/kramdown/parser/kramdown/list.rb +13 -9
- data/lib/kramdown/parser/kramdown/math.rb +1 -1
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +4 -4
- data/lib/kramdown/utils.rb +36 -0
- data/lib/kramdown/utils/entities.rb +338 -0
- data/lib/kramdown/utils/html.rb +72 -0
- data/lib/kramdown/version.rb +1 -1
- data/man/man1/kramdown.1 +20 -17
- data/test/run_tests.rb +1 -1
- data/test/test_files.rb +60 -3
- data/test/testcases/block/06_codeblock/whitespace.html +2 -2
- data/test/testcases/block/07_horizontal_rule/error.html.19 +7 -0
- data/test/testcases/block/09_html/html_to_native/code.html +1 -1
- data/test/testcases/block/09_html/html_to_native/code.text +1 -1
- data/test/testcases/block/09_html/html_to_native/table_simple.html +38 -2
- data/test/testcases/block/09_html/html_to_native/table_simple.text +42 -0
- data/test/testcases/block/09_html/html_to_native/typography.html.19 +1 -0
- data/test/testcases/block/09_html/simple.html.19 +62 -0
- data/test/testcases/block/11_ial/simple.html +3 -2
- data/test/testcases/block/12_extension/comment.html +3 -2
- data/test/testcases/block/12_extension/options.html +0 -3
- data/test/testcases/block/12_extension/options.text +0 -6
- data/test/testcases/block/13_definition_list/item_ial.html +14 -0
- data/test/testcases/block/13_definition_list/item_ial.text +8 -0
- data/test/testcases/block/16_toc/no_toc_depth.html +33 -0
- data/test/testcases/block/16_toc/no_toc_depth.options +1 -0
- data/test/testcases/block/16_toc/no_toc_depth.text +16 -0
- data/test/testcases/block/16_toc/toc_depth_2.html +24 -0
- data/test/testcases/block/16_toc/toc_depth_2.options +1 -0
- data/test/testcases/block/16_toc/toc_depth_2.text +16 -0
- data/test/testcases/span/01_link/empty.html +2 -0
- data/test/testcases/span/01_link/empty.text +2 -0
- data/test/testcases/span/01_link/imagelinks.html +2 -0
- data/test/testcases/span/01_link/imagelinks.text +2 -0
- data/test/testcases/span/01_link/inline.html.19 +40 -0
- data/test/testcases/span/01_link/reference.html.19 +32 -0
- data/test/testcases/span/extension/comment.html +3 -3
- data/test/testcases/span/text_substitutions/entities.html.19 +4 -0
- data/test/testcases/span/text_substitutions/entities_numeric.html +1 -0
- data/test/testcases/span/text_substitutions/entities_numeric.html.19 +1 -0
- data/test/testcases/span/text_substitutions/entities_numeric.options +1 -0
- data/test/testcases/span/text_substitutions/entities_numeric.text +1 -0
- data/test/testcases/span/text_substitutions/typography.html.19 +18 -0
- metadata +30 -10
- data/test/testcases/block/09_html/filtered_html.html +0 -1
- data/test/testcases/block/09_html/filtered_html.options +0 -1
- data/test/testcases/block/09_html/filtered_html.text +0 -1
data/lib/kramdown/version.rb
CHANGED
data/man/man1/kramdown.1
CHANGED
@@ -133,23 +133,6 @@ Default: 1
|
|
133
133
|
Used by: HTML converter
|
134
134
|
|
135
135
|
|
136
|
-
.TP
|
137
|
-
.B \-\-filter_html ARG
|
138
|
-
|
139
|
-
NOTE: This option is deprecated and will be removed in a future release!
|
140
|
-
|
141
|
-
An array of HTML tags that should be filtered from the output
|
142
|
-
|
143
|
-
The value can either be specified as array or as a space separated
|
144
|
-
string (which will be converted to an array). All HTML tags that are
|
145
|
-
listed in the array will be filtered from the output, i.e. only their
|
146
|
-
contents is used. This applies only to HTML tags found in the initial
|
147
|
-
document.
|
148
|
-
|
149
|
-
Default: []
|
150
|
-
Used by: HTML converter
|
151
|
-
|
152
|
-
|
153
136
|
.TP
|
154
137
|
.B \-\-coderay_wrap ARG
|
155
138
|
|
@@ -212,6 +195,26 @@ Default: style
|
|
212
195
|
Used by: HTML converter
|
213
196
|
|
214
197
|
|
198
|
+
.TP
|
199
|
+
.B \-\-[no\-]numeric_entities
|
200
|
+
|
201
|
+
Defines whether entities are output using names or numeric values
|
202
|
+
|
203
|
+
Default: false
|
204
|
+
Used by: HTML converter, kramdown converter
|
205
|
+
|
206
|
+
|
207
|
+
.TP
|
208
|
+
.B \-\-toc_depth ARG
|
209
|
+
|
210
|
+
Defines the maximum level of headers which will be used to generate the table of
|
211
|
+
contents. For instance, with a value of 2, toc entries will be generated for h1
|
212
|
+
and h2 headers but not for h3, h4, etc. A value of 0 uses all header levels.
|
213
|
+
|
214
|
+
Default: 0
|
215
|
+
Used by: HTML/Latex converter
|
216
|
+
|
217
|
+
|
215
218
|
.SH SEE ALSO
|
216
219
|
The kramdown website, http://kramdown.rubyforge.org/ for more information, especially on the support
|
217
220
|
input syntax.
|
data/test/run_tests.rb
CHANGED
@@ -45,7 +45,7 @@ Dir[arg].each {|f| fwidth = [fwidth, f.length + 10].max }.each do |file|
|
|
45
45
|
html_file = file.sub('.text', '.html')
|
46
46
|
opts_file = file.sub('.text', '.options')
|
47
47
|
opts_file = File.join(File.dirname(file), 'options') if !File.exist?(opts_file)
|
48
|
-
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :
|
48
|
+
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
|
49
49
|
doc = Kramdown::Document.new(File.read(file), options)
|
50
50
|
begin
|
51
51
|
assert_equal(File.read(html_file), doc.to_html)
|
data/test/test_files.rb
CHANGED
@@ -25,6 +25,8 @@ require 'kramdown'
|
|
25
25
|
require 'yaml'
|
26
26
|
require 'tmpdir'
|
27
27
|
|
28
|
+
Encoding.default_external = 'utf-8' if RUBY_VERSION >= '1.9'
|
29
|
+
|
28
30
|
class TestFiles < Test::Unit::TestCase
|
29
31
|
|
30
32
|
# Generate test methods for kramdown-to-xxx conversion
|
@@ -32,11 +34,13 @@ class TestFiles < Test::Unit::TestCase
|
|
32
34
|
basename = text_file.sub(/\.text$/, '')
|
33
35
|
opts_file = text_file.sub(/\.text$/, '.options')
|
34
36
|
(Dir[basename + ".*"] - [text_file, opts_file]).each do |output_file|
|
35
|
-
|
37
|
+
next if (RUBY_VERSION >= '1.9' && File.exist?(output_file + '.19')) ||
|
38
|
+
(RUBY_VERSION < '1.9' && output_file =~ /\.19$/)
|
39
|
+
output_format = File.extname(output_file.sub(/\.19$/, ''))[1..-1]
|
36
40
|
next if !Kramdown::Converter.const_defined?(output_format[0..0].upcase + output_format[1..-1])
|
37
41
|
define_method('test_' + text_file.tr('.', '_') + "_to_#{output_format}") do
|
38
42
|
opts_file = File.join(File.dirname(text_file), 'options') if !File.exist?(opts_file)
|
39
|
-
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :
|
43
|
+
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
|
40
44
|
doc = Kramdown::Document.new(File.read(text_file), options)
|
41
45
|
assert_equal(File.read(output_file), doc.send("to_#{output_format}"))
|
42
46
|
end
|
@@ -61,7 +65,8 @@ class TestFiles < Test::Unit::TestCase
|
|
61
65
|
end
|
62
66
|
|
63
67
|
def tidy_output(out)
|
64
|
-
|
68
|
+
cmd = "tidy -q --doctype omit #{RUBY_VERSION >= '1.9' ? '-utf8' : '-raw'} 2>/dev/null"
|
69
|
+
result = IO.popen(cmd, 'r+') do |io|
|
65
70
|
io.write(out)
|
66
71
|
io.close_write
|
67
72
|
io.read
|
@@ -97,4 +102,56 @@ class TestFiles < Test::Unit::TestCase
|
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
105
|
+
# Generate test methods for text->kramdown->html conversion
|
106
|
+
`tidy -v 2>&1`
|
107
|
+
if $?.exitstatus != 0
|
108
|
+
warn("Skipping text->kramdown->html tests because tidy executable is missing")
|
109
|
+
else
|
110
|
+
EXCLUDE_TEXT_FILES = ['test/testcases/span/05_html/markdown_attr.text', # bc of markdown attr
|
111
|
+
'test/testcases/block/09_html/markdown_attr.text', # bc of markdown attr
|
112
|
+
'test/testcases/span/extension/options.text', # bc of parse_span_html option
|
113
|
+
'test/testcases/block/12_extension/options.text', # bc of options option
|
114
|
+
'test/testcases/block/12_extension/options3.text', # bc of options option
|
115
|
+
'test/testcases/block/09_html/content_model/tables.text', # bc of parse_block_html option
|
116
|
+
'test/testcases/block/09_html/html_to_native/header.text', # bc of auto_ids option that interferes
|
117
|
+
'test/testcases/block/09_html/simple.text', # bc of webgen:block elements
|
118
|
+
]
|
119
|
+
Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
|
120
|
+
next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/}
|
121
|
+
define_method('test_' + text_file.tr('.', '_') + "_to_kramdown_to_html") do
|
122
|
+
html_file = text_file.sub(/\.text$/, '.html')
|
123
|
+
html_file += '.19' if RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')
|
124
|
+
opts_file = text_file.sub(/\.text$/, '.options')
|
125
|
+
opts_file = File.join(File.dirname(text_file), 'options') if !File.exist?(opts_file)
|
126
|
+
options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
|
127
|
+
kdtext = Kramdown::Document.new(File.read(text_file), options).to_kramdown
|
128
|
+
html = Kramdown::Document.new(kdtext, options).to_html
|
129
|
+
assert_equal(tidy_output(File.read(html_file)), tidy_output(html))
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Generate test methods for html-to-kramdown-to-html conversion
|
135
|
+
`tidy -v 2>&1`
|
136
|
+
if $?.exitstatus != 0
|
137
|
+
warn("Skipping html-to-kramdown-to-html tests because tidy executable is missing")
|
138
|
+
else
|
139
|
+
EXCLUDE_HTML_KD_FILES = ['test/testcases/span/extension/options.html', # bc of parse_span_html option
|
140
|
+
'test/testcases/span/05_html/normal.html', # bc of br tag before closing p tag
|
141
|
+
'test/testcases/block/12_extension/nomarkdown.html', # bc of nomarkdown extension
|
142
|
+
'test/testcases/block/09_html/simple.html', # bc of webgen:block elements
|
143
|
+
'test/testcases/block/09_html/markdown_attr.html', # bc of markdown attr
|
144
|
+
'test/testcases/block/09_html/html_to_native/table_simple.html', # bc of invalidly converted simple table
|
145
|
+
'test/testcases/block/06_codeblock/whitespace.html', # bc of entity to char conversion
|
146
|
+
]
|
147
|
+
Dir[File.dirname(__FILE__) + '/testcases/**/*.html'].each do |html_file|
|
148
|
+
next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}$/}
|
149
|
+
define_method('test_' + html_file.tr('.', '_') + "_to_kramdown_to_html") do
|
150
|
+
kd = Kramdown::Document.new(File.read(html_file), :input => 'html', :auto_ids => false, :footnote_nr => 1).to_kramdown
|
151
|
+
doc = Kramdown::Document.new(kd, :auto_ids => false, :footnote_nr => 1)
|
152
|
+
assert_equal(tidy_output(File.read(html_file)), tidy_output(doc.to_html))
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
100
157
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<pre class="show-whitespaces"><code>This<span class="ws-tab"> </span>is<span class="ws-space"
|
2
|
-
<span class="ws-space-l"
|
1
|
+
<pre class="show-whitespaces"><code>This<span class="ws-tab"> </span>is<span class="ws-space">⋅</span>some<span class="ws-space-r">⋅</span><span class="ws-space-r">⋅</span>
|
2
|
+
<span class="ws-space-l">⋅</span><span class="ws-space-l">⋅</span><span class="ws-space-l">⋅</span><span class="ws-space-l">⋅</span>whitespace<span class="ws-space-r">⋅</span><span class="ws-space-r">⋅</span>
|
3
3
|
</code></pre>
|
@@ -1,10 +1,46 @@
|
|
1
|
+
<table class="examples">
|
2
|
+
<tbody>
|
3
|
+
<tr>
|
4
|
+
<td>Usage</td>
|
5
|
+
<td>Output</td>
|
6
|
+
</tr>
|
7
|
+
<tr>
|
8
|
+
<td>Some *data*</td>
|
9
|
+
<td>Some more</td>
|
10
|
+
</tr>
|
11
|
+
</tbody>
|
12
|
+
</table>
|
13
|
+
|
14
|
+
<table class="examples">
|
15
|
+
<thead>
|
16
|
+
<tr>
|
17
|
+
<th>Usage</th>
|
18
|
+
<th>Output</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<tr>
|
23
|
+
<td>Some *data*</td>
|
24
|
+
<td>Some more</td>
|
25
|
+
</tr>
|
26
|
+
</tbody>
|
27
|
+
<tfoot>
|
28
|
+
<tr>
|
29
|
+
<td>foot</td>
|
30
|
+
<td>locker</td>
|
31
|
+
</tr>
|
32
|
+
</tfoot>
|
33
|
+
</table>
|
34
|
+
|
1
35
|
<table class="examples">
|
2
36
|
<tr>
|
3
37
|
<th>Usage</th>
|
4
38
|
<th>Output</th>
|
5
39
|
</tr>
|
6
40
|
<tr>
|
7
|
-
<td>
|
8
|
-
|
41
|
+
<td>
|
42
|
+
Some *data* </td>
|
43
|
+
<td>
|
44
|
+
Some more </td>
|
9
45
|
</tr>
|
10
46
|
</table>
|
@@ -1,3 +1,45 @@
|
|
1
|
+
<table class="examples">
|
2
|
+
<tr>
|
3
|
+
<td>Usage</td>
|
4
|
+
<td>
|
5
|
+
Output
|
6
|
+
</td>
|
7
|
+
</tr>
|
8
|
+
<tr>
|
9
|
+
<td>Some *data*</td>
|
10
|
+
<td>
|
11
|
+
Some more
|
12
|
+
</td>
|
13
|
+
</tr>
|
14
|
+
</table>
|
15
|
+
|
16
|
+
<table class="examples">
|
17
|
+
<thead>
|
18
|
+
<tr>
|
19
|
+
<th>Usage</th>
|
20
|
+
<th>
|
21
|
+
Output
|
22
|
+
</th>
|
23
|
+
</tr>
|
24
|
+
</thead>
|
25
|
+
<tbody>
|
26
|
+
<tr>
|
27
|
+
<td>Some *data*</td>
|
28
|
+
<td>
|
29
|
+
Some more
|
30
|
+
</td>
|
31
|
+
</tr>
|
32
|
+
</tbody>
|
33
|
+
<tfoot>
|
34
|
+
<tr>
|
35
|
+
<td>foot</td>
|
36
|
+
<td>
|
37
|
+
locker
|
38
|
+
</td>
|
39
|
+
</tr>
|
40
|
+
</tfoot>
|
41
|
+
</table>
|
42
|
+
|
1
43
|
<table class="examples">
|
2
44
|
<tr>
|
3
45
|
<th>Usage</th>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>This is … something “to remember”!</p>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<div>
|
2
|
+
<p>test</p>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<p>
|
6
|
+
para2
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<div id="test">
|
10
|
+
<p>tes</p>
|
11
|
+
|
12
|
+
<p>test
|
13
|
+
weiter
|
14
|
+
</p>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<p>para4</p>
|
18
|
+
|
19
|
+
<div>
|
20
|
+
<div>
|
21
|
+
<div>
|
22
|
+
<p>foo</p>
|
23
|
+
</div>
|
24
|
+
<div style=" "></div>
|
25
|
+
</div>
|
26
|
+
<div>
|
27
|
+
<p>bar </p>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<p>para5</p>
|
32
|
+
|
33
|
+
<div>
|
34
|
+
<p>id</p>
|
35
|
+
</div>
|
36
|
+
<p>test</p>
|
37
|
+
|
38
|
+
<div>
|
39
|
+
<p>hallo</p>
|
40
|
+
</div>
|
41
|
+
<div>
|
42
|
+
<p>hallo</p>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<p>para6</p>
|
46
|
+
|
47
|
+
<div>
|
48
|
+
<div class="clear"></div>
|
49
|
+
<p>Another para.</p>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<webgen:block name="test" />
|
53
|
+
|
54
|
+
<some:url name:spac="hallo">doit</some:url>
|
55
|
+
|
56
|
+
<p><em>Test</em></p>
|
57
|
+
|
58
|
+
<p><em>Test</em></p>
|
59
|
+
|
60
|
+
<p><em>Test
|
61
|
+
</em>
|
62
|
+
</p>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<ul id="markdown-toc">
|
2
|
+
<li><a href="#header-level-1">Header level 1</a> <ul>
|
3
|
+
<li><a href="#header-level-2">Header level 2</a> <ul>
|
4
|
+
<li><a href="#header-level-3">Header level 3</a> <ul>
|
5
|
+
<li><a href="#header-level-4">Header level 4</a></li>
|
6
|
+
</ul>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
</li>
|
10
|
+
</ul>
|
11
|
+
</li>
|
12
|
+
<li><a href="#other-header-level-1">Other header level 1</a> <ul>
|
13
|
+
<li><a href="#other-header-level-2">Other header level 2</a> <ul>
|
14
|
+
<li><a href="#other-header-level-3">Other header level 3</a></li>
|
15
|
+
</ul>
|
16
|
+
</li>
|
17
|
+
</ul>
|
18
|
+
</li>
|
19
|
+
</ul>
|
20
|
+
|
21
|
+
<h1 id="header-level-1">Header level 1</h1>
|
22
|
+
|
23
|
+
<h2 id="header-level-2">Header level 2</h2>
|
24
|
+
|
25
|
+
<h3 id="header-level-3">Header level 3</h3>
|
26
|
+
|
27
|
+
<h4 id="header-level-4">Header level 4</h4>
|
28
|
+
|
29
|
+
<h1 id="other-header-level-1">Other header level 1</h1>
|
30
|
+
|
31
|
+
<h2 id="other-header-level-2">Other header level 2</h2>
|
32
|
+
|
33
|
+
<h3 id="other-header-level-3">Other header level 3</h3>
|