kramdown 0.11.0 → 0.12.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 (94) hide show
  1. data/CONTRIBUTERS +1 -1
  2. data/ChangeLog +532 -0
  3. data/README +22 -12
  4. data/Rakefile +9 -8
  5. data/VERSION +1 -1
  6. data/benchmark/benchmark.sh +61 -0
  7. data/benchmark/generate_data.rb +57 -55
  8. data/benchmark/testing.sh +1 -1
  9. data/benchmark/timing.sh +3 -3
  10. data/bin/kramdown +1 -2
  11. data/data/kramdown/document.html +2 -2
  12. data/data/kramdown/document.latex +2 -2
  13. data/doc/default.scss.css +6 -1
  14. data/doc/default.template +1 -1
  15. data/doc/documentation.page +1 -1
  16. data/doc/index.page +9 -7
  17. data/doc/installation.page +2 -3
  18. data/doc/links.markdown +1 -1
  19. data/doc/quickref.page +19 -19
  20. data/doc/syntax.page +117 -98
  21. data/doc/tests.page +8 -7
  22. data/lib/kramdown/compatibility.rb +2 -1
  23. data/lib/kramdown/converter.rb +5 -7
  24. data/lib/kramdown/converter/base.rb +87 -32
  25. data/lib/kramdown/converter/html.rb +134 -122
  26. data/lib/kramdown/converter/kramdown.rb +24 -25
  27. data/lib/kramdown/converter/latex.rb +65 -55
  28. data/lib/kramdown/document.rb +487 -42
  29. data/lib/kramdown/error.rb +3 -0
  30. data/lib/kramdown/options.rb +83 -28
  31. data/lib/kramdown/parser.rb +5 -5
  32. data/lib/kramdown/parser/base.rb +55 -13
  33. data/lib/kramdown/parser/html.rb +83 -71
  34. data/lib/kramdown/parser/kramdown.rb +73 -54
  35. data/lib/kramdown/parser/kramdown/abbreviation.rb +17 -12
  36. data/lib/kramdown/parser/kramdown/autolink.rb +2 -3
  37. data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
  38. data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
  39. data/lib/kramdown/parser/kramdown/blockquote.rb +2 -2
  40. data/lib/kramdown/parser/kramdown/codeblock.rb +5 -2
  41. data/lib/kramdown/parser/kramdown/codespan.rb +1 -2
  42. data/lib/kramdown/parser/kramdown/emphasis.rb +1 -1
  43. data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
  44. data/lib/kramdown/parser/kramdown/extensions.rb +204 -0
  45. data/lib/kramdown/parser/kramdown/footnote.rb +7 -7
  46. data/lib/kramdown/parser/kramdown/header.rb +4 -2
  47. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
  48. data/lib/kramdown/parser/kramdown/html.rb +39 -45
  49. data/lib/kramdown/parser/kramdown/link.rb +19 -29
  50. data/lib/kramdown/parser/kramdown/list.rb +13 -13
  51. data/lib/kramdown/parser/kramdown/math.rb +1 -1
  52. data/lib/kramdown/parser/kramdown/paragraph.rb +5 -4
  53. data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
  54. data/lib/kramdown/parser/kramdown/table.rb +51 -12
  55. data/lib/kramdown/parser/markdown.rb +69 -0
  56. data/lib/kramdown/utils.rb +2 -2
  57. data/lib/kramdown/utils/entities.rb +10 -1
  58. data/lib/kramdown/utils/html.rb +22 -11
  59. data/lib/kramdown/utils/ordered_hash.rb +44 -40
  60. data/lib/kramdown/version.rb +1 -1
  61. data/man/man1/kramdown.1 +31 -4
  62. data/test/testcases/block/08_list/item_ial.html +1 -1
  63. data/test/testcases/block/11_ial/nested.html +11 -0
  64. data/test/testcases/block/11_ial/nested.text +15 -0
  65. data/test/testcases/block/13_definition_list/item_ial.html +1 -1
  66. data/test/testcases/block/14_table/escaping.html +52 -0
  67. data/test/testcases/block/14_table/escaping.text +19 -0
  68. data/test/testcases/block/14_table/simple.html.19 +139 -0
  69. data/test/testcases/block/14_table/simple.text +1 -1
  70. data/test/testcases/block/15_math/normal.html +13 -13
  71. data/test/testcases/block/16_toc/{no_toc_depth.html → no_toc.html} +0 -0
  72. data/test/testcases/block/16_toc/{no_toc_depth.options → no_toc.options} +0 -0
  73. data/test/testcases/block/16_toc/{no_toc_depth.text → no_toc.text} +0 -0
  74. data/test/testcases/block/16_toc/{toc_depth_2.html → toc_levels.html} +4 -4
  75. data/test/testcases/block/16_toc/toc_levels.options +1 -0
  76. data/test/testcases/block/16_toc/{toc_depth_2.text → toc_levels.text} +0 -0
  77. data/test/testcases/span/escaped_chars/normal.html +4 -0
  78. data/test/testcases/span/escaped_chars/normal.text +4 -0
  79. data/test/testcases/span/ial/simple.html +1 -1
  80. data/test/testcases/span/math/normal.html +2 -2
  81. metadata +20 -25
  82. data/benchmark/historic-jruby-1.4.0.dat +0 -7
  83. data/benchmark/historic-ruby-1.8.6.dat +0 -7
  84. data/benchmark/historic-ruby-1.8.7.dat +0 -7
  85. data/benchmark/historic-ruby-1.9.1p243.dat +0 -7
  86. data/benchmark/historic-ruby-1.9.2dev.dat +0 -7
  87. data/benchmark/static-jruby-1.4.0.dat +0 -7
  88. data/benchmark/static-ruby-1.8.6.dat +0 -7
  89. data/benchmark/static-ruby-1.8.7.dat +0 -7
  90. data/benchmark/static-ruby-1.9.1p243.dat +0 -7
  91. data/benchmark/static-ruby-1.9.2dev.dat +0 -7
  92. data/lib/kramdown/parser/kramdown/attribute_list.rb +0 -111
  93. data/lib/kramdown/parser/kramdown/extension.rb +0 -116
  94. data/test/testcases/block/16_toc/toc_depth_2.options +0 -1
@@ -1,7 +0,0 @@
1
- # kramdown 0.1.0 || kramdown 0.2.0 || kramdown 0.3.0 || kramdown 0.4.0 || kramdown 0.5.0 || kramdown 0.6.0
2
- 1 0.21300 0.31800 0.16800 0.30400 0.30800 0.17300
3
- 2 0.20700 0.22600 0.26700 0.23400 0.26800 0.39000
4
- 4 0.22000 0.21700 0.20400 0.19300 0.19400 0.19300
5
- 8 0.36300 0.44500 0.30100 0.29500 0.32800 0.31900
6
- 16 0.45400 0.53400 0.46200 0.48900 0.50200 0.51000
7
- 32 1.02800 0.98100 0.84600 0.81900 0.72200 0.68500
@@ -1,7 +0,0 @@
1
- # kramdown 0.1.0 || kramdown 0.2.0 || kramdown 0.3.0 || kramdown 0.4.0 || kramdown 0.5.0 || kramdown 0.6.0
2
- 1 0.01211 0.01274 0.01385 0.01359 0.01539 0.01531
3
- 2 0.02449 0.02582 0.02924 0.02691 0.03194 0.03106
4
- 4 0.08228 0.08475 0.08600 0.09013 0.05768 0.05841
5
- 8 0.12842 0.13410 0.14426 0.13687 0.14952 0.15120
6
- 16 0.22743 0.27748 0.29497 0.28115 0.26786 0.27056
7
- 32 0.45690 0.51838 0.54252 0.51869 0.57976 0.51855
@@ -1,7 +0,0 @@
1
- # kramdown 0.1.0 || kramdown 0.2.0 || kramdown 0.3.0 || kramdown 0.4.0 || kramdown 0.5.0 || kramdown 0.6.0
2
- 1 0.01259 0.01329 0.01580 0.01397 0.01554 0.01583
3
- 2 0.02472 0.02672 0.02858 0.02849 0.03387 0.03192
4
- 4 0.09610 0.08355 0.05439 0.05232 0.05801 0.06041
5
- 8 0.13269 0.13811 0.10869 0.10471 0.15673 0.15005
6
- 16 0.27243 0.27540 0.28680 0.27240 0.31712 0.31372
7
- 32 0.52890 0.55667 0.54547 0.52283 0.60766 0.59042
@@ -1,7 +0,0 @@
1
- # kramdown 0.1.0 || kramdown 0.2.0 || kramdown 0.3.0 || kramdown 0.4.0 || kramdown 0.5.0 || kramdown 0.6.0
2
- 1 0.02062 0.02216 0.02152 0.02025 0.01289 0.01334
3
- 2 0.04097 0.04290 0.03939 0.03956 0.02890 0.02739
4
- 4 0.07696 0.08015 0.09122 0.07573 0.06272 0.06234
5
- 8 0.16986 0.16998 0.16856 0.16380 0.11127 0.11350
6
- 16 0.33684 0.34800 0.35242 0.33358 0.23528 0.23868
7
- 32 0.68273 0.70498 0.74138 0.66569 0.44669 0.45204
@@ -1,7 +0,0 @@
1
- # kramdown 0.1.0 || kramdown 0.2.0 || kramdown 0.3.0 || kramdown 0.4.0 || kramdown 0.5.0 || kramdown 0.6.0
2
- 1 0.01827 0.02000 0.01830 0.02061 0.01632 0.01618
3
- 2 0.03951 0.04158 0.04056 0.04378 0.03590 0.03532
4
- 4 0.08055 0.08419 0.08363 0.08286 0.04809 0.04781
5
- 8 0.14925 0.15101 0.15830 0.14567 0.10250 0.10226
6
- 16 0.31483 0.31485 0.31176 0.30726 0.20651 0.20778
7
- 32 0.62318 0.64162 0.61918 0.59270 0.42345 0.42295
@@ -1,7 +0,0 @@
1
- # Maruku 0.6.0 || BlueFeather 0.33 || BlueCloth Not Available. || RDiscount Not Available.
2
- 1 0.07500 0.08500 0.00000 0.00000
3
- 2 0.14400 0.22800 0.00000 0.00000
4
- 4 0.28300 0.61100 0.00000 0.00000
5
- 8 0.62300 1.94700 0.00000 0.00000
6
- 16 1.30400 7.11800 0.00000 0.00000
7
- 32 2.56900 28.30800 0.00000 0.00000
@@ -1,7 +0,0 @@
1
- # Maruku 0.6.0 || BlueFeather 0.32 || BlueCloth 2.0.5 || RDiscount 1.3.5
2
- 1 0.06202 0.12554 0.00055 0.00061
3
- 2 0.11490 0.42433 0.00150 0.00104
4
- 4 0.22792 1.35390 0.00189 0.00210
5
- 8 0.50887 4.93941 0.00363 0.00411
6
- 16 1.11704 18.90444 0.00792 0.00937
7
- 32 2.36787 78.08507 0.01822 0.02148
@@ -1,7 +0,0 @@
1
- # Maruku 0.6.0 || BlueFeather 0.32 || BlueCloth 2.0.5 || RDiscount 1.3.5
2
- 1 0.06325 0.13453 0.00060 0.00058
3
- 2 0.12058 0.45557 0.00108 0.00115
4
- 4 0.24777 1.47726 0.00219 0.00237
5
- 8 0.49758 5.21774 0.00401 0.00460
6
- 16 1.18307 20.93746 0.00916 0.01011
7
- 32 2.65514 81.59896 0.02015 0.02210
@@ -1,7 +0,0 @@
1
- # Maruku 0.6.0 || BlueFeather 0.32 || BlueCloth 2.0.5 || RDiscount 1.3.5
2
- 1 0.07650 0.16749 0.00067 0.00070
3
- 2 0.22272 0.54882 0.00146 0.00132
4
- 4 0.30977 1.95581 0.00248 0.00265
5
- 8 0.61692 7.35415 0.00453 0.00555
6
- 16 1.35505 28.91778 0.00939 0.01241
7
- 32 3.00461 115.68435 0.02550 0.02510
@@ -1,7 +0,0 @@
1
- # Maruku 0.6.0 || BlueFeather 0.32 || BlueCloth 2.0.5 || RDiscount 1.3.5
2
- 1 0.05888 0.12860 0.00063 0.00059
3
- 2 0.18025 0.40292 0.00115 0.00108
4
- 4 0.24735 1.51833 0.00353 0.00299
5
- 8 0.51102 6.07239 0.00410 0.00497
6
- 16 1.03159 23.21515 0.01348 0.01277
7
- 32 2.61620 92.00956 0.01893 0.02003
@@ -1,111 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- #--
4
- # Copyright (C) 2009-2010 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
- module Parser
25
- class Kramdown
26
-
27
- # Parse the string +str+ and extract all attributes and add all found attributes to the hash
28
- # +opts+.
29
- def parse_attribute_list(str, opts)
30
- str.scan(ALD_TYPE_ANY).each do |key, sep, val, id_attr, class_attr, ref|
31
- if ref
32
- (opts[:refs] ||= []) << ref
33
- elsif class_attr
34
- opts['class'] = ((opts['class'] || '') + " #{class_attr}").lstrip
35
- elsif id_attr
36
- opts['id'] = id_attr
37
- else
38
- opts[key] = val.gsub(/\\(\}|#{sep})/, "\\1")
39
- end
40
- end
41
- end
42
-
43
- # Update the +ial+ with the information from the inline attribute list +opts+.
44
- def update_ial_with_ial(ial, opts)
45
- (ial[:refs] ||= []) << opts[:refs]
46
- opts.each do |k,v|
47
- if k == 'class'
48
- ial[k] = ((ial[k] || '') + " #{v}").lstrip
49
- elsif k.kind_of?(String)
50
- ial[k] = v
51
- end
52
- end
53
- end
54
-
55
-
56
- ALD_ID_CHARS = /[\w-]/
57
- ALD_ANY_CHARS = /\\\}|[^\}]/
58
- ALD_ID_NAME = /\w#{ALD_ID_CHARS}*/
59
- ALD_TYPE_KEY_VALUE_PAIR = /(#{ALD_ID_NAME})=("|')((?:\\\}|\\\2|[^\}\2])*?)\2/
60
- ALD_TYPE_CLASS_NAME = /\.(#{ALD_ID_NAME})/
61
- ALD_TYPE_ID_NAME = /#(\w[\w:-]*)/
62
- ALD_TYPE_REF = /(#{ALD_ID_NAME})/
63
- ALD_TYPE_ANY = /(?:\A|\s)(?:#{ALD_TYPE_KEY_VALUE_PAIR}|#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME}|#{ALD_TYPE_REF})(?=\s|\Z)/
64
- ALD_START = /^#{OPT_SPACE}\{:(#{ALD_ID_NAME}):(#{ALD_ANY_CHARS}+)\}\s*?\n/
65
-
66
- # Parse the attribute list definition at the current location.
67
- def parse_ald
68
- @src.pos += @src.matched_size
69
- parse_attribute_list(@src[2], @doc.parse_infos[:ald][@src[1]] ||= Utils::OrderedHash.new)
70
- @tree.children << Element.new(:eob, :ald)
71
- true
72
- end
73
- define_parser(:ald, ALD_START)
74
-
75
-
76
- IAL_BLOCK = /\{:(?!:|\/)(#{ALD_ANY_CHARS}+)\}\s*?\n/
77
- IAL_BLOCK_START = /^#{OPT_SPACE}#{IAL_BLOCK}/
78
-
79
- # Parse the inline attribute list at the current location.
80
- def parse_block_ial
81
- @src.pos += @src.matched_size
82
- if @tree.children.last && @tree.children.last.type != :blank && @tree.children.last.type != :eob
83
- parse_attribute_list(@src[1], @tree.children.last.options[:ial] ||= Utils::OrderedHash.new)
84
- @tree.children << Element.new(:eob, :ial) unless @src.check(IAL_BLOCK_START)
85
- else
86
- parse_attribute_list(@src[1], @block_ial = Utils::OrderedHash.new)
87
- end
88
- true
89
- end
90
- define_parser(:block_ial, IAL_BLOCK_START)
91
-
92
-
93
- IAL_SPAN_START = /\{:(#{ALD_ANY_CHARS}+)\}/
94
-
95
- # Parse the inline attribute list at the current location.
96
- def parse_span_ial
97
- @src.pos += @src.matched_size
98
- if @tree.children.last && @tree.children.last.type != :text
99
- attr = Utils::OrderedHash.new
100
- parse_attribute_list(@src[1], attr)
101
- update_ial_with_ial(@tree.children.last.options[:ial] ||= Utils::OrderedHash.new, attr)
102
- update_attr_with_ial(@tree.children.last.attr, attr)
103
- else
104
- warning("Ignoring span IAL because preceding element is just text")
105
- end
106
- end
107
- define_parser(:span_ial, IAL_SPAN_START, '\{:')
108
-
109
- end
110
- end
111
- end
@@ -1,116 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- #--
4
- # Copyright (C) 2009-2010 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
- require 'kramdown/parser/kramdown/attribute_list'
24
-
25
- module Kramdown
26
- module Parser
27
- class Kramdown
28
-
29
- def parse_extension_start_tag(type)
30
- orig_pos = @src.pos
31
- @src.pos += @src.matched_size
32
-
33
- error_block = lambda do |msg|
34
- warning(msg)
35
- @src.pos = orig_pos
36
- add_text(@src.scan(/./)) if type == :span
37
- false
38
- end
39
-
40
- if @src[4] || @src.matched == '{:/}'
41
- name = (@src[4] ? "for '#{@src[4]}' " : '')
42
- return error_block.call("Invalid extension stop tag #{name}found - ignoring it")
43
- end
44
-
45
- ext = @src[1]
46
- opts = {}
47
- body = nil
48
- parse_attribute_list(@src[2] || '', opts)
49
-
50
- if !@src[3]
51
- stop_re = (type == :block ? /#{EXT_BLOCK_STOP_STR % ext}/ : /#{EXT_STOP_STR % ext}/)
52
- if result = @src.scan_until(stop_re)
53
- body = result.sub!(stop_re, '')
54
- body.chomp! if type == :block
55
- else
56
- return error_block.call("No stop tag for extension '#{ext}' found - ignoring it")
57
- end
58
- end
59
-
60
- if !handle_extension(ext, opts, body, type)
61
- error_block.call("Invalid extension with name '#{ext}' specified - ignoring it")
62
- else
63
- true
64
- end
65
- end
66
-
67
- def handle_extension(name, opts, body, type)
68
- case name
69
- when 'comment'
70
- @tree.children << Element.new(:comment, body, nil, :category => type) if body.kind_of?(String)
71
- true
72
- when 'nomarkdown'
73
- @tree.children << Element.new(:raw, body, nil, :category => type, :type => opts['type'].to_s.split(/\s+/)) if body.kind_of?(String)
74
- true
75
- when 'options'
76
- opts.select do |k,v|
77
- k = k.to_sym
78
- if Kramdown::Options.defined?(k)
79
- @doc.options[k] = Kramdown::Options.parse(k, v) rescue @doc.options[k]
80
- false
81
- else
82
- true
83
- end
84
- end.each do |k,v|
85
- warning("Unknown kramdown option '#{k}'")
86
- end
87
- @tree.children << Element.new(:eob, :extension) if type == :block
88
- true
89
- else
90
- false
91
- end
92
- end
93
-
94
-
95
- EXT_STOP_STR = "\\{:/(%s)?\\}"
96
- EXT_START_STR = "\\{::(\\w+)(?:\\s(#{ALD_ANY_CHARS}*?)|)(\\/)?\\}"
97
- EXT_SPAN_START = /#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME}/
98
- EXT_BLOCK_START = /^#{OPT_SPACE}(?:#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME})\s*?\n/
99
- EXT_BLOCK_STOP_STR = "^#{OPT_SPACE}#{EXT_STOP_STR}\s*?\n"
100
-
101
- # Parse the extension block at the current location.
102
- def parse_block_extension
103
- parse_extension_start_tag(:block)
104
- end
105
- define_parser(:block_extension, EXT_BLOCK_START)
106
-
107
-
108
- # Parse the extension span at the current location.
109
- def parse_span_extension
110
- parse_extension_start_tag(:span)
111
- end
112
- define_parser(:span_extension, EXT_SPAN_START, '\{:[:/]')
113
-
114
- end
115
- end
116
- end
@@ -1 +0,0 @@
1
- :toc_depth: 2