kramdown 0.1.0 → 0.2.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 (87) hide show
  1. data/COPYING +1 -1
  2. data/ChangeLog +423 -1
  3. data/Rakefile +5 -5
  4. data/VERSION +1 -1
  5. data/doc/default.template +4 -4
  6. data/doc/index.page +5 -4
  7. data/doc/news.feed +1 -1
  8. data/doc/quickref.page +72 -25
  9. data/doc/syntax.page +238 -66
  10. data/doc/tests.page +2 -3
  11. data/lib/kramdown/converter.rb +41 -10
  12. data/lib/kramdown/deprecated.rb +41 -0
  13. data/lib/kramdown/document.rb +17 -8
  14. data/lib/kramdown/extension.rb +13 -7
  15. data/lib/kramdown/parser.rb +263 -95
  16. data/lib/kramdown/version.rb +28 -0
  17. data/test/run_tests.rb +1 -1
  18. data/test/test_files.rb +1 -1
  19. data/test/testcases/block/02_eob/middle.html +1 -0
  20. data/test/testcases/block/04_header/atx_header.html +8 -0
  21. data/test/testcases/block/04_header/atx_header.text +8 -0
  22. data/test/testcases/block/04_header/setext_header.html +6 -0
  23. data/test/testcases/block/04_header/setext_header.text +9 -0
  24. data/test/testcases/block/07_horizontal_rule/sepspaces.html +3 -0
  25. data/test/testcases/block/07_horizontal_rule/sepspaces.text +3 -0
  26. data/test/testcases/block/07_horizontal_rule/septabs.html +3 -0
  27. data/test/testcases/block/07_horizontal_rule/septabs.text +3 -0
  28. data/test/testcases/block/09_html/content_model/deflists.html +6 -0
  29. data/test/testcases/block/09_html/content_model/deflists.options +1 -0
  30. data/test/testcases/block/09_html/content_model/deflists.text +6 -0
  31. data/test/testcases/block/09_html/content_model/tables.html +14 -0
  32. data/test/testcases/block/09_html/content_model/tables.options +1 -0
  33. data/test/testcases/block/09_html/content_model/tables.text +14 -0
  34. data/test/testcases/block/09_html/html_and_codeblocks.options +1 -1
  35. data/test/testcases/block/09_html/invalid_html_1.html +0 -2
  36. data/test/testcases/block/09_html/invalid_html_2.html +2 -3
  37. data/test/testcases/block/09_html/markdown_attr.html +38 -0
  38. data/test/testcases/block/09_html/markdown_attr.text +38 -0
  39. data/test/testcases/block/09_html/not_parsed.html +14 -0
  40. data/test/testcases/block/09_html/not_parsed.text +15 -0
  41. data/test/testcases/block/09_html/parse_as_raw.html +16 -14
  42. data/test/testcases/block/09_html/parse_as_raw.options +1 -0
  43. data/test/testcases/block/09_html/parse_as_raw.text +13 -1
  44. data/test/testcases/block/09_html/parse_as_span.html +2 -5
  45. data/test/testcases/block/09_html/parse_as_span.options +1 -0
  46. data/test/testcases/block/09_html/{auto_parse_block_html.html → parse_block_html.html} +0 -0
  47. data/test/testcases/block/09_html/parse_block_html.options +1 -0
  48. data/test/testcases/block/09_html/{auto_parse_block_html.text → parse_block_html.text} +0 -0
  49. data/test/testcases/block/09_html/simple.html +21 -30
  50. data/test/testcases/block/09_html/simple.options +1 -0
  51. data/test/testcases/block/09_html/simple.text +13 -2
  52. data/test/testcases/block/11_ial/auto_id_and_ial.html +1 -0
  53. data/test/testcases/block/11_ial/auto_id_and_ial.options +1 -0
  54. data/test/testcases/block/11_ial/auto_id_and_ial.text +2 -0
  55. data/test/testcases/block/12_extension/{nokramdown.html → nomarkdown.html} +0 -0
  56. data/test/testcases/block/12_extension/{nokramdown.text → nomarkdown.text} +4 -4
  57. data/test/testcases/block/12_extension/{kdoptions.html → options.html} +9 -0
  58. data/test/testcases/block/12_extension/options.text +28 -0
  59. data/test/testcases/block/12_extension/{kdoptions2.html → options2.html} +0 -0
  60. data/test/testcases/block/12_extension/{kdoptions2.text → options2.text} +1 -1
  61. data/test/testcases/block/13_definition_list/definition_at_beginning.html +1 -0
  62. data/test/testcases/block/13_definition_list/definition_at_beginning.text +1 -0
  63. data/test/testcases/block/13_definition_list/multiple_terms.html +13 -0
  64. data/test/testcases/block/13_definition_list/multiple_terms.text +10 -0
  65. data/test/testcases/block/13_definition_list/para_wrapping.html +10 -0
  66. data/test/testcases/block/13_definition_list/para_wrapping.text +6 -0
  67. data/test/testcases/block/13_definition_list/separated_by_eob.html +8 -0
  68. data/test/testcases/block/13_definition_list/separated_by_eob.text +5 -0
  69. data/test/testcases/block/13_definition_list/simple.html +8 -0
  70. data/test/testcases/block/13_definition_list/simple.text +7 -0
  71. data/test/testcases/block/13_definition_list/styled_terms.html +4 -0
  72. data/test/testcases/block/13_definition_list/styled_terms.text +2 -0
  73. data/test/testcases/block/13_definition_list/too_much_space.html +3 -0
  74. data/test/testcases/block/13_definition_list/too_much_space.text +4 -0
  75. data/test/testcases/block/13_definition_list/with_blocks.html +38 -0
  76. data/test/testcases/block/13_definition_list/with_blocks.text +24 -0
  77. data/test/testcases/span/05_html/across_lines.html +1 -0
  78. data/test/testcases/span/05_html/across_lines.text +2 -0
  79. data/test/testcases/span/05_html/link_with_mailto.html +1 -0
  80. data/test/testcases/span/05_html/link_with_mailto.text +1 -0
  81. data/test/testcases/span/05_html/markdown_attr.html +5 -0
  82. data/test/testcases/span/05_html/markdown_attr.text +5 -0
  83. data/test/testcases/span/05_html/normal.html +7 -0
  84. data/test/testcases/span/05_html/normal.text +7 -0
  85. metadata +56 -12
  86. data/test/testcases/block/09_html/auto_parse_block_html.options +0 -1
  87. data/test/testcases/block/12_extension/kdoptions.text +0 -18
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown.
7
+ #
8
+ # kramdown is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ #++
21
+ #
22
+
23
+ module Kramdown
24
+
25
+ # The kramdown version.
26
+ VERSION = '0.2.0'
27
+
28
+ end
data/test/run_tests.rb CHANGED
@@ -44,7 +44,7 @@ Dir[arg].each {|f| fwidth = [fwidth, f.length + 10].max }.each do |file|
44
44
 
45
45
  html_file = file.sub('.text', '.html')
46
46
  opts_file = file.sub('.text', '.options')
47
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {}
47
+ options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :filter_html => [], :footnote_nr => 1}
48
48
  doc = Kramdown::Document.new(File.read(file), options)
49
49
  begin
50
50
  assert_equal(File.read(html_file), doc.to_html)
data/test/test_files.rb CHANGED
@@ -30,7 +30,7 @@ class TestFiles < Test::Unit::TestCase
30
30
  define_method('test_' + file.tr('.', '_')) do
31
31
  html_file = file.sub('.text', '.html')
32
32
  opts_file = file.sub('.text', '.options')
33
- options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {}
33
+ options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :filter_html => [], :footnote_nr => 1}
34
34
  doc = Kramdown::Document.new(File.read(file), options)
35
35
  assert_equal(File.read(html_file), doc.to_html, "Failed test #{file}")
36
36
  end
@@ -23,4 +23,12 @@
23
23
  </blockquote>
24
24
  <p>### not a header</p>
25
25
 
26
+ <h3 id="id">Header</h3>
27
+
28
+ <h3 id="id">Header</h3>
29
+
30
+ <h3>Header{#noid}</h3>
31
+
32
+ <h3>Header ##{#noid}</h3>
33
+
26
34
  <h3>Last</h3>
@@ -21,4 +21,12 @@ paragraph
21
21
  > blockquote
22
22
  ### not a header
23
23
 
24
+ ### Header {#id}
25
+
26
+ ### Header ## {#id}
27
+
28
+ ### Header{#noid}
29
+
30
+ ### Header ##{#noid}
31
+
24
32
  ### Last
@@ -22,4 +22,10 @@ And not a header.
22
22
  <p>Not a Header</p>
23
23
  <hr />
24
24
 
25
+ <h2 id="id">header</h2>
26
+
27
+ <h1 id="id">header</h1>
28
+
29
+ <h2>header{#noid}</h2>
30
+
25
31
  <h2>header</h2>
@@ -23,5 +23,14 @@ And not a header.
23
23
  Not a Header
24
24
  ---
25
25
 
26
+ header {#id}
27
+ ------------
28
+
29
+ header {#id}
30
+ ======
31
+
32
+ header{#noid}
33
+ -----
34
+
26
35
  header
27
36
  ------
@@ -0,0 +1,3 @@
1
+ <hr />
2
+ <hr />
3
+ <hr />
@@ -0,0 +1,3 @@
1
+ - - -
2
+ * * *
3
+ _ _ _ _ _
@@ -0,0 +1,3 @@
1
+ <hr />
2
+ <hr />
3
+ <hr />
@@ -0,0 +1,3 @@
1
+ - - -
2
+ * * *
3
+ _ _ _ _ _
@@ -0,0 +1,6 @@
1
+ <dl>
2
+ <dt><em>text</em></dt>
3
+ <dd>
4
+ <p>para</p>
5
+ </dd>
6
+ </dl>
@@ -0,0 +1 @@
1
+ :parse_block_html: true
@@ -0,0 +1,6 @@
1
+ <dl>
2
+ <dt>*text*</dt>
3
+ <dd>
4
+ para
5
+ </dd>
6
+ </dl>
@@ -0,0 +1,14 @@
1
+ <table class="examples">
2
+ <tr>
3
+ <th><em>Usage</em></th>
4
+ <th>
5
+ <p>Output</p>
6
+ </th>
7
+ </tr>
8
+ <tr>
9
+ <td>Some <em>data</em></td>
10
+ <td>
11
+ <h1 id="some-more">Some more</h1>
12
+ </td>
13
+ </tr>
14
+ </table>
@@ -0,0 +1 @@
1
+ :parse_block_html: true
@@ -0,0 +1,14 @@
1
+ <table class="examples">
2
+ <tr>
3
+ <th>*Usage*</th>
4
+ <th>
5
+ Output
6
+ </th>
7
+ </tr>
8
+ <tr>
9
+ <td>Some *data*</td>
10
+ <td>
11
+ # Some more
12
+ </td>
13
+ </tr>
14
+ </table>
@@ -1 +1 @@
1
- :auto_parse_block_html: false
1
+ :parse_block_html: true
@@ -1,5 +1,3 @@
1
1
  <p>para</p>
2
2
 
3
- &lt;/div&gt;
4
-
5
3
  <p>para</p>
@@ -1,6 +1,5 @@
1
1
  <p>para</p>
2
2
 
3
- <hr>
3
+ <hr />
4
4
 
5
- para
6
- </hr>
5
+ <p>para</p>
@@ -0,0 +1,38 @@
1
+ <div>
2
+ <p><em>para</em></p>
3
+ </div>
4
+
5
+ <div>
6
+ <em>para</em>
7
+ </div>
8
+
9
+ <div>
10
+ <p><em>para</em></p>
11
+ </div>
12
+
13
+ <div>
14
+ *para*
15
+ </div>
16
+
17
+ <p>
18
+ <p><em>para</em></p>
19
+ </p>
20
+
21
+ <p>
22
+ <em>para</em>
23
+ </p>
24
+
25
+ <p>
26
+ <em>para</em>
27
+ </p>
28
+
29
+ <p>
30
+ *para*
31
+ </p>
32
+
33
+ <dl>
34
+ <dt><em>emphasize</em></dt>
35
+ <dd>
36
+ <p>para</p>
37
+ </dd>
38
+ </dl>
@@ -0,0 +1,38 @@
1
+ <div markdown="block">
2
+ *para*
3
+ </div>
4
+
5
+ <div markdown="span">
6
+ *para*
7
+ </div>
8
+
9
+ <div markdown="1">
10
+ *para*
11
+ </div>
12
+
13
+ <div markdown="0">
14
+ *para*
15
+ </div>
16
+
17
+ <p markdown="block">
18
+ *para*
19
+ </p>
20
+
21
+ <p markdown="span">
22
+ *para*
23
+ </p>
24
+
25
+ <p markdown="1">
26
+ *para*
27
+ </p>
28
+
29
+ <p markdown="0">
30
+ *para*
31
+ </p>
32
+
33
+ <dl>
34
+ <dt markdown="1">*emphasize*</dt>
35
+ <dd markdown="1">
36
+ para
37
+ </dd>
38
+ </dl>
@@ -0,0 +1,14 @@
1
+ <div>
2
+ This is some text
3
+ </div>
4
+
5
+ <div><div>
6
+ This is some text
7
+ </div></div>
8
+
9
+ <div>
10
+ </div>
11
+
12
+ <div>
13
+ <p><a href="/">Foo</a></p>
14
+ </div>
@@ -0,0 +1,15 @@
1
+ <div>
2
+ This is some text
3
+ </div>
4
+
5
+ <div><div>
6
+ This is some text
7
+ </div></div>
8
+
9
+ <div>
10
+ </p>
11
+ </div>
12
+
13
+ <div>
14
+ <p><a href="/">Foo</a></p>
15
+ </div>
@@ -1,26 +1,28 @@
1
1
  <p>This is some para.</p>
2
2
  <script type="javascript">
3
3
  This *text* must not be converted.
4
- </script>
4
+ </script>
5
5
 
6
- <script>
7
- Not *parsed* here
8
- </script>
6
+ <script>Not *parsed* here</script>
9
7
 
10
- <script>
11
- *not*
12
- </script>
13
- <p>
14
- <em>parsed</em>
8
+ <script>*not*</script>
9
+ <p><em>parsed</em>
15
10
  This too
16
11
  </p>
17
12
 
18
- <script>
19
- *not*<p>*parsed*
13
+ <script>*not*<p>*parsed*
20
14
  This too
21
- </p>
22
- </script>
15
+ </p></script>
16
+
17
+ <script>something<p>*not*</p></script>
23
18
 
19
+ <script></script>
20
+
21
+ <script>
22
+ This should be output
23
+ <p> *as* is
24
+ </p> and nothing should be done
25
+ about it
24
26
  <script>
25
- something<p>*not*</p>
27
+ </script>
26
28
  </script>
@@ -0,0 +1 @@
1
+ :parse_block_html: true
@@ -1,7 +1,7 @@
1
1
  This is some para.
2
2
  <script type="javascript">
3
3
  This *text* must not be converted.
4
- </script>
4
+ </script>
5
5
 
6
6
  <script>Not *parsed* here</script>
7
7
 
@@ -14,3 +14,15 @@ This too
14
14
  </p></script>
15
15
 
16
16
  <script>something<p>*not*</p></script>
17
+
18
+ <script></script>
19
+
20
+ <script>
21
+ This should be output
22
+ <p> *as* is
23
+ </p> and nothing should be done
24
+ about it
25
+ <script>
26
+ </not>
27
+ </p>
28
+ </script>
@@ -1,12 +1,9 @@
1
- <p>
2
- This <em>text
1
+ <p>This <em>text
3
2
  should</em> be parsed
4
3
  as span
5
4
  </p>
6
5
 
7
- <p>
8
- This <em>text</em> too
9
- </p>
6
+ <p>This <em>text</em> too</p>
10
7
  <p>
11
8
  some text
12
9
  </p>
@@ -0,0 +1 @@
1
+ :parse_block_html: true
@@ -0,0 +1 @@
1
+ :parse_block_html: true
@@ -7,14 +7,11 @@ para2
7
7
  </p>
8
8
 
9
9
  <div id="test">
10
- <p>
11
- tes
12
- </p>
10
+ <p>tes</p>
13
11
 
14
- <p>
15
- test
12
+ <p>test
16
13
  weiter
17
- </p>
14
+ </p>
18
15
  </div>
19
16
 
20
17
  <p>para4</p>
@@ -26,37 +23,25 @@ weiter
26
23
  </div>
27
24
  <div style="&nbsp;"></div>
28
25
  </div>
29
- <div>
30
- bar&nbsp;
31
- </div>
26
+ <div>bar&nbsp;</div>
32
27
  </div>
33
28
 
34
29
  <p>para5</p>
35
30
 
36
- <div>
37
- id
38
- </div>
31
+ <div>id</div>
39
32
 
40
- <div>
41
- id
33
+ <div>id
42
34
  </div>
35
+ test
43
36
 
44
- <div>
45
- hallo&lt;/p&gt;
46
- <div>
47
- test
48
- </div>
37
+ <div>hallo<div>test</div>
49
38
  <p>hallo</p>
50
39
  </div>
51
40
 
52
- <div>
53
- hallo
54
- <div>
55
- test
41
+ <div>hallo<div>test
42
+ <p>hallo</p>
56
43
  </div>
57
- <p>hallo</p>
58
44
  </div>
59
- &lt;/p&gt;
60
45
 
61
46
  <div>
62
47
  <p>hallo</p>
@@ -65,14 +50,20 @@ test
65
50
  <p>hallo</p>
66
51
  </div>
67
52
 
53
+ <p>para6</p>
54
+
55
+ <div><div class="clear"></div>
56
+ <p>Another para.</p>
57
+ </div>
58
+
68
59
  <webgen:block name="test" />
69
60
 
70
- <some:url name:spac="hallo">
71
- doit
72
- </some:url>
61
+ <some:url name:spac="hallo">doit</some:url>
73
62
 
74
63
  <p><em>Test</em></p>
75
64
 
76
- <p>
77
- <em>Test</em>
65
+ <p><em>Test</em></p>
66
+
67
+ <p><em>Test
68
+ </em>
78
69
  </p>