kramdown 1.3.3 → 1.4.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +4 -2
  3. data/Rakefile +9 -0
  4. data/VERSION +1 -1
  5. data/doc/documentation.template +1 -0
  6. data/doc/index.page +7 -5
  7. data/doc/installation.page +2 -2
  8. data/doc/sidebar.template +2 -2
  9. data/doc/syntax.page +7 -2
  10. data/lib/kramdown/converter/html.rb +9 -1
  11. data/lib/kramdown/converter/kramdown.rb +5 -2
  12. data/lib/kramdown/parser/gfm.rb +9 -4
  13. data/lib/kramdown/parser/html.rb +4 -4
  14. data/lib/kramdown/parser/kramdown.rb +2 -2
  15. data/lib/kramdown/parser/kramdown/link.rb +3 -1
  16. data/lib/kramdown/parser/kramdown/list.rb +14 -4
  17. data/lib/kramdown/parser/kramdown/table.rb +5 -2
  18. data/lib/kramdown/utils/entities.rb +11 -0
  19. data/lib/kramdown/utils/string_scanner.rb +10 -0
  20. data/lib/kramdown/version.rb +1 -1
  21. data/man/man1/kramdown.1 +4 -4
  22. data/test/test_files.rb +1 -0
  23. data/test/test_location.rb +16 -2
  24. data/test/testcases/block/09_html/html_to_native/table_simple.html +13 -0
  25. data/test/testcases/block/09_html/html_to_native/table_simple.text +15 -0
  26. data/test/testcases/block/15_math/gh_128.html +2 -0
  27. data/test/testcases/block/15_math/gh_128.text +1 -0
  28. data/test/testcases/block/15_math/normal.html +2 -0
  29. data/test/testcases/block/15_math/normal.text +2 -0
  30. data/test/testcases/span/01_link/imagelinks.html +1 -0
  31. data/test/testcases/span/01_link/imagelinks.text +2 -0
  32. data/test/testcases/span/04_footnote/placement.html +11 -0
  33. data/test/testcases/span/04_footnote/placement.text +8 -0
  34. data/test/testcases/span/05_html/normal.html +7 -0
  35. data/test/testcases/span/05_html/normal.text +7 -0
  36. data/test/testcases/span/05_html/raw_span_elements.html +2 -0
  37. data/test/testcases/span/05_html/raw_span_elements.text +2 -0
  38. data/test/testcases_gfm/atx_header.html +3 -0
  39. data/test/testcases_gfm/atx_header.text +3 -0
  40. metadata +10 -4
  41. data/benchmark/graph-ruby-2.1.0p0-0.png +0 -0
  42. data/benchmark/kramdown-ruby-2.1.0p0-0.dat +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fca305ca569f78677eaee502ca58f498f0ff42e
4
- data.tar.gz: c1387c873ca7463f987a57c67ce330f50267bfbd
3
+ metadata.gz: 7bc587193307dcea4710eed05bfa2060a518c67e
4
+ data.tar.gz: 712948207deb53058cfd494b071874d1c867c309
5
5
  SHA512:
6
- metadata.gz: 409dfa7e4150ec35d541222f6a36341c8c5fa0640084df8cd39f49c6797077dd7ddd3fa6bb2ad14352766a6a5cabc9d5529bc26384f8aaceacfdb23208f2f10a
7
- data.tar.gz: 7e842beafe84355582a19ad225f27f0b072a3454095aa82a4402369e239d6ec39c366866e7745ec8cd2e0b7bc42063f8bcbc2e93a505c33428db2cd7b6120ee4
6
+ metadata.gz: 83c5923ed5c7d2268ef7a6a4056a8f27b52845c78eb30af5d14c42f75ac5d496e24fd5a0b8479cbf145c064de4862b46ad8194b07aca5a57b5752d4714538a54
7
+ data.tar.gz: 6b49da8d9362d5f47a3181e36977c1d3d6a996b8fb062e7e496eb323f8a38604a3e14c722f75be33c671f3850178e8deb2451dbdbb1345e4ccedff82766c2362
@@ -1,6 +1,6 @@
1
1
  Count Name
2
2
  ======= ====
3
- 656 Thomas Leitner <t_leitner@gmx.at>
3
+ 676 Thomas Leitner <t_leitner@gmx.at>
4
4
  6 Gioele Barabucci <gioele@svario.it>
5
5
  4 Ted Pak <powerpak006@gmail.com>
6
6
  4 Arne Brasseur <arne@arnebrasseur.net>
@@ -9,12 +9,15 @@
9
9
  3 Brandur <brandur@mutelight.org>
10
10
  3 Ben Armston <ben.armston@googlemail.com>
11
11
  3 Alex Marandon <contact@alexmarandon.com>
12
+ 2 Nathanael Jones <nathanael.jones@gmail.com>
13
+ 2 Jo Hund <jhund@clearcove.ca>
12
14
  2 Bran <m.versum@gmail.com>
13
15
  1 Trevor Wennblom <trevor@well.com>
14
16
  1 tomykaira <tomykaira@gmail.com>
15
17
  1 Tim Besard <tim.besard@gmail.com>
16
18
  1 Tim Bates <tim@rumpuslabs.com>
17
19
  1 Simon Lydell <simon.lydell@gmail.com>
20
+ 1 Shusaku NAKAZATO <cu393uc@gmail.com>
18
21
  1 Postmodern <postmodern.mod3@gmail.com>
19
22
  1 Pete Michaud <michaudp@gmail.com>
20
23
  1 myqlarson <myqlarson@gmail.com>
@@ -22,7 +25,6 @@
22
25
  1 Matt Hickford <matt.hickford@gmail.com>
23
26
  1 Marcus Stollsteimer <sto.mar@web.de>
24
27
  1 Luca Barbato <luca.barbato@gmail.com>
25
- 1 Jo Hund <jhund@clearcove.ca>
26
28
  1 John Croisant <jacius@gmail.com>
27
29
  1 Joe Fiorini <joe@faithfulgeek.org>
28
30
  1 Damien Pollet <damien.pollet@gmail.com>
data/Rakefile CHANGED
@@ -192,6 +192,13 @@ EOF
192
192
  s.homepage = "http://kramdown.gettalong.org"
193
193
  end
194
194
 
195
+
196
+ task :gemspec => [ 'CONTRIBUTERS', 'VERSION', 'man/man1/kramdown.1'] do
197
+ print "Generating Gemspec\n"
198
+ contents = spec.to_ruby
199
+ File.open("kramdown.gemspec", 'w+') {|f| f.puts(contents)}
200
+ end
201
+
195
202
  Gem::PackageTask.new(spec) do |pkg|
196
203
  pkg.need_zip = true
197
204
  pkg.need_tar = true
@@ -255,4 +262,6 @@ EOF
255
262
 
256
263
  end
257
264
 
265
+ task :gemspec => ['dev:gemspec']
266
+
258
267
  task :clobber => ['dev:clobber']
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.3
1
+ 1.4.0
@@ -4,6 +4,7 @@
4
4
  * Parsers
5
5
  * [kramdown](parser/kramdown.html)
6
6
  * [Markdown](parser/markdown.html)
7
+ * [GFM](parser/gfm.html)
7
8
  * [HTML](parser/html.html)
8
9
  * Converters
9
10
  * [HTML](converter/html.html)
@@ -25,9 +25,10 @@ content_processor.tikz.opts: |
25
25
  level 2 concept/.append style={font=\Large},
26
26
  }
27
27
  \node[concept, font=\Large] (lib) {kramdown's internal representation}
28
- child[concept color=orange, grow=140, ->] {node[concept] (i-kramdown) {kramdown}}
29
- child[concept color=orange, grow=180] {node[concept] (i-html) {HTML}}
30
- child[concept color=orange, grow=220] {node[concept] (i-markdown) {Markdown}}
28
+ child[concept color=orange, grow=120, ->] {node[concept] (i-kramdown) {kramdown}}
29
+ child[concept color=orange, grow=160] {node[concept] (i-html) {HTML}}
30
+ child[concept color=orange, grow=200] {node[concept] (i-gfm) {GFM}}
31
+ child[concept color=orange, grow=240] {node[concept] (i-markdown) {Markdown}}
31
32
  child[concept color=green!50!black, grow=60] {node[concept] (o-html) {HTML}}
32
33
  child[concept color=green!50!black, grow=20] {node[concept] (o-kramdown) {kramdown}}
33
34
  child[concept color=green!50!black, grow=-20] {
@@ -41,7 +42,8 @@ content_processor.tikz.opts: |
41
42
  \draw [dash pattern=on 0pt off 2pt,line width=5pt,arrows=-angle 60,shorten >=15pt,shorten <=10pt,color=orange]
42
43
  (i-kramdown) edge(lib)
43
44
  (i-markdown) edge(lib)
44
- (i-html) edge (lib);
45
+ (i-html) edge (lib)
46
+ (i-gfm) edge (lib);
45
47
  \draw [dash pattern=on 0pt off 2pt,line width=5pt,arrows=-angle 60,shorten >=10pt,shorten <=15pt,color=green!50!black]
46
48
  (lib) edge(o-html)
47
49
  (lib) edge (o-kramdown)
@@ -70,7 +72,7 @@ Markdown implementations because kramdown borrowed many ideas from existing pack
70
72
  ## Author
71
73
 
72
74
  * Thomas Leitner
73
- * e-Mail: <t_leitner@gmx.at>
75
+ * e-Mail: <mailto:t_leitner@gmx.at>
74
76
 
75
77
 
76
78
  [PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/
@@ -32,9 +32,9 @@ Ubuntu version or any recent Debian based distribution).
32
32
  After running the following commands, kramdown is installed and ready to use:
33
33
 
34
34
  sudo aptitude install ruby rubygems
35
- sudo gem1.8 install kramdown
35
+ sudo gem install kramdown
36
36
 
37
- > You will also need to add `export PATH=$PATH:/var/lib/gems/1.8/bin` to your `~/.bashrc` because
37
+ > You will also need to add `export PATH=$PATH:/var/lib/gems/1.9/bin` to your `~/.bashrc` because
38
38
  > this is the binary path the executable files get installed to.
39
39
 
40
40
 
@@ -1,7 +1,7 @@
1
1
  <h2>News</h2>
2
2
 
3
- <p>The latest version of kramdown is <span class="inline-important">1.3.3</span> and it was released
4
- on <span class="inline-important">2014-03-17</span></p>
3
+ <p>The latest version of kramdown is <span class="inline-important">1.4.0</span> and it was released
4
+ on <span class="inline-important">2014-06-18</span></p>
5
5
 
6
6
  <p>More <a href="{relocatable: news.html}">news</a>…</p>
7
7
 
@@ -920,6 +920,11 @@ Using inline math is also easy: just surround your math content with two dollar
920
920
  math block. If you don't want to start an inline math statement, just escape the dollar signs and
921
921
  they will be treated as simple dollar signs.
922
922
 
923
+ > **Note** that LaTeX code that uses the pipe symbol `|` in inline math statements may lead to a
924
+ > line being recognized as a table line. This problem can be avoided by using the `\vert` command
925
+ > instead of `|`!
926
+ {:.information}
927
+
923
928
  If you have a paragraph that looks like a math block but should actually be a paragraph with just an
924
929
  inline math statement, you need to escape the first dollar sign:
925
930
 
@@ -1005,9 +1010,9 @@ basis using the `markdown` attribute:
1005
1010
  The following list shows which HTML tags are parsed in which mode by default when `markdown="1"` is
1006
1011
  applied or `parse_block_html` is `true`:
1007
1012
 
1008
- Parse as raw HTML block
1013
+ Parse as raw HTML
1009
1014
  :
1010
- script math option textarea
1015
+ script style math option textarea pre code kbd samp var
1011
1016
 
1012
1017
  Also, all general XML tags are parsed as raw HTML blocks.
1013
1018
 
@@ -49,6 +49,7 @@ module Kramdown
49
49
  @footnote_counter = @footnote_start = @options[:footnote_nr]
50
50
  @footnotes = []
51
51
  @footnotes_by_name = {}
52
+ @footnote_location = nil
52
53
  @toc = []
53
54
  @toc_code = nil
54
55
  @indent = 2
@@ -149,6 +150,8 @@ module Kramdown
149
150
  if !@toc_code && (el.options[:ial][:refs].include?('toc') rescue nil)
150
151
  @toc_code = [el.type, el.attr, (0..128).to_a.map{|a| rand(36).to_s(36)}.join]
151
152
  @toc_code.last
153
+ elsif !@footnote_location && el.options[:ial] && (el.options[:ial][:refs] || []).include?('footnotes')
154
+ @footnote_location = (0..128).to_a.map{|a| rand(36).to_s(36)}.join
152
155
  else
153
156
  format_as_indented_block_html(el.type, el.attr, inner(el, indent), indent)
154
157
  end
@@ -318,6 +321,7 @@ module Kramdown
318
321
  def convert_math(el, indent)
319
322
  block = (el.options[:category] == :block)
320
323
  value = (el.value =~ /<|&/ ? "% <![CDATA[\n#{el.value} %]]>" : el.value)
324
+ value.gsub!(/<\/?script>?/, '')
321
325
  type = {:type => "math/tex#{block ? '; mode=display' : ''}"}
322
326
  if block
323
327
  format_as_block_html('script', type, value, indent)
@@ -333,7 +337,11 @@ module Kramdown
333
337
 
334
338
  def convert_root(el, indent)
335
339
  result = inner(el, indent)
336
- result << footnote_content
340
+ if @footnote_location
341
+ result.sub!(/#{@footnote_location}/, footnote_content)
342
+ else
343
+ result << footnote_content
344
+ end
337
345
  if @toc_code
338
346
  toc_tree = generate_toc_tree(@toc, @toc_code[0], @toc_code[1] || {})
339
347
  text = if toc_tree.children.size > 0
@@ -285,8 +285,9 @@ module Kramdown
285
285
  end
286
286
 
287
287
  def convert_img(el, opts)
288
+ alt_text = el.attr['alt'].gsub(ESCAPED_CHAR_RE) { $1 ? "\\#{$1}" : $2 }
288
289
  if el.attr['src'].empty?
289
- "![#{el.attr['alt']}]()"
290
+ "![#{alt_text}]()"
290
291
  else
291
292
  title = (el.attr['title'] ? ' "' + el.attr['title'].gsub(/"/, "&quot;") + '"' : '')
292
293
  link = if el.attr['src'].count("()") > 0
@@ -294,7 +295,7 @@ module Kramdown
294
295
  else
295
296
  el.attr['src']
296
297
  end
297
- "![#{el.attr['alt']}](#{link}#{title})"
298
+ "![#{alt_text}](#{link}#{title})"
298
299
  end
299
300
  end
300
301
 
@@ -408,6 +409,8 @@ module Kramdown
408
409
  end.compact.join('')
409
410
  res = "toc" << (res.strip.empty? ? '' : " #{res}") if (el.type == :ul || el.type == :ol) &&
410
411
  (el.options[:ial][:refs].include?('toc') rescue nil)
412
+ res = "footnotes" << (res.strip.empty? ? '' : " #{res}") if (el.type == :ul || el.type == :ol) &&
413
+ (el.options[:ial][:refs].include?('footnotes') rescue nil)
411
414
  res.strip.empty? ? nil : "{:#{res}}"
412
415
  end
413
416
 
@@ -9,9 +9,12 @@ module Kramdown
9
9
  def initialize(source, options)
10
10
  super
11
11
  @span_parsers.delete(:line_break)
12
- i = @block_parsers.index(:codeblock_fenced)
13
- @block_parsers.delete(:codeblock_fenced)
14
- @block_parsers.insert(i, :codeblock_fenced_gfm)
12
+ {:codeblock_fenced => :codeblock_fenced_gfm,
13
+ :atx_header => :atx_header_gfm}.each do |current, replacement|
14
+ i = @block_parsers.index(current)
15
+ @block_parsers.delete(current)
16
+ @block_parsers.insert(i, replacement)
17
+ end
15
18
  end
16
19
 
17
20
  def parse
@@ -38,8 +41,10 @@ module Kramdown
38
41
  end.flatten!
39
42
  end
40
43
 
41
- FENCED_CODEBLOCK_MATCH = /^(([~`]){3,})\s*?(\w+)?\s*?\n(.*?)^\1\2*\s*?\n/m
44
+ ATX_HEADER_START = /^\#{1,6}\s/
45
+ define_parser(:atx_header_gfm, ATX_HEADER_START, nil, 'parse_atx_header')
42
46
 
47
+ FENCED_CODEBLOCK_MATCH = /^(([~`]){3,})\s*?(\w+)?\s*?\n(.*?)^\1\2*\s*?\n/m
43
48
  define_parser(:codeblock_fenced_gfm, /^[~`]{3,}/, nil, 'parse_codeblock_fenced')
44
49
 
45
50
  end
@@ -37,9 +37,9 @@ module Kramdown
37
37
  dd div dl fieldset figure figcaption footer form header hgroup iframe li map menu nav
38
38
  noscript object section td}
39
39
  HTML_CONTENT_MODEL_SPAN = %w{a abbr acronym b bdo big button cite caption del dfn dt em
40
- h1 h2 h3 h4 h5 h6 i ins kbd label legend optgroup p q rb rbc
41
- rp rt rtc ruby samp select small span strong sub sup summary th tt var}
42
- HTML_CONTENT_MODEL_RAW = %w{script style math option textarea pre code}
40
+ h1 h2 h3 h4 h5 h6 i ins label legend optgroup p q rb rbc
41
+ rp rt rtc ruby select small span strong sub sup summary th tt}
42
+ HTML_CONTENT_MODEL_RAW = %w{script style math option textarea pre code kbd samp var}
43
43
  # The following elements are also parsed as raw since they need child elements that cannot
44
44
  # be expressed using kramdown syntax: colgroup table tbody thead tfoot tr ul ol
45
45
 
@@ -420,7 +420,7 @@ module Kramdown
420
420
  if td.attr['style']
421
421
  td.attr['style'].slice!(/(?:;\s*)?text-align:\s+(center|left|right)/)
422
422
  td.attr.delete('style') if td.attr['style'].strip.empty?
423
- $1.to_sym
423
+ $1 ? $1.to_sym : :default
424
424
  else
425
425
  :default
426
426
  end
@@ -74,8 +74,8 @@ module Kramdown
74
74
 
75
75
  @block_parsers = [:blank_line, :codeblock, :codeblock_fenced, :blockquote, :atx_header,
76
76
  :horizontal_rule, :list, :definition_list, :block_html, :setext_header,
77
- :table, :footnote_definition, :link_definition, :abbrev_definition,
78
- :block_extensions, :block_math, :eob_marker, :paragraph]
77
+ :block_math, :table, :footnote_definition, :link_definition, :abbrev_definition,
78
+ :block_extensions, :eob_marker, :paragraph]
79
79
  @span_parsers = [:emphasis, :codespan, :autolink, :span_html, :footnote_marker, :link, :smart_quotes, :inline_math,
80
80
  :span_extensions, :html_entity, :typographic_syms, :line_break, :escaped_chars]
81
81
 
@@ -7,6 +7,8 @@
7
7
  #++
8
8
  #
9
9
 
10
+ require 'kramdown/parser/kramdown/escaped_chars'
11
+
10
12
  module Kramdown
11
13
  module Parser
12
14
  class Kramdown
@@ -76,7 +78,7 @@ module Kramdown
76
78
  add_text(result)
77
79
  return
78
80
  end
79
- alt_text = extract_string(reset_pos...@src.pos, @src)
81
+ alt_text = extract_string(reset_pos...@src.pos, @src).gsub(ESCAPED_CHARS, '\1')
80
82
  @src.scan(LINK_BRACKET_STOP_RE)
81
83
 
82
84
  # reference style link or no link url
@@ -76,19 +76,20 @@ module Kramdown
76
76
  /^( {0,#{[3, indentation - 1].min}}\d+\.)([\t| ].*?\n)/)
77
77
  nested_list_found = (item.value =~ LIST_START)
78
78
  last_is_blank = false
79
+ item.value = [item.value]
79
80
  elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re)))
80
81
  result.sub!(/^(\t+)/) { " "*($1 ? 4*$1.length : 0) }
81
82
  result.sub!(indent_re, '')
82
83
  if !nested_list_found && result =~ LIST_START
83
- item.value << "^\n"
84
+ item.value << ''
84
85
  nested_list_found = true
85
86
  end
86
- item.value << result
87
+ item.value.last << result
87
88
  last_is_blank = false
88
89
  elsif result = @src.scan(BLANK_LINE)
89
90
  nested_list_found = true
90
91
  last_is_blank = true
91
- item.value << result
92
+ item.value.last << result
92
93
  else
93
94
  break
94
95
  end
@@ -99,7 +100,16 @@ module Kramdown
99
100
  last = nil
100
101
  list.children.each do |it|
101
102
  temp = Element.new(:temp, nil, nil, :location => it.options[:location])
102
- parse_blocks(temp, it.value)
103
+
104
+ env = save_env
105
+ location = it.options[:location]
106
+ it.value.each do |val|
107
+ @src = ::Kramdown::Utils::StringScanner.new(val, location)
108
+ parse_blocks(temp)
109
+ location = @src.current_line_number
110
+ end
111
+ restore_env(env)
112
+
103
113
  it.children = temp.children
104
114
  it.value = nil
105
115
  next if it.children.size == 0
@@ -114,10 +114,13 @@ module Kramdown
114
114
  @src.current_line_number)
115
115
  reset_env(:src => l_src)
116
116
  root = Element.new(:root)
117
- parse_spans(root, nil, [:codespan])
117
+ parse_spans(root, nil, [:codespan, :span_html])
118
118
  restore_env(env)
119
119
 
120
- # Check if each line has at least one unescaped backslash that is not inside a code span
120
+ # Check if each line has at least one unescaped pipe that is not inside a code span/code
121
+ # HTML element
122
+ # Note: It doesn't matter that we parse *all* span HTML elements because the row splitting
123
+ # algorithm above only takes <code> elements into account!
121
124
  pipe_on_line = false
122
125
  while (c = root.children.shift)
123
126
  lines = c.value.split(/\n/)
@@ -79,9 +79,15 @@ module Kramdown
79
79
  [969, 'omega'],
80
80
  [962, 'sigmaf'],
81
81
  [977, 'thetasym'],
82
+ [978, 'upsih'],
82
83
  [982, 'piv'],
84
+ [8204, 'zwnj'],
85
+ [8205, 'zwj'],
86
+ [8206, 'lrm'],
87
+ [8207, 'rlm'],
83
88
  [8230, 'hellip'],
84
89
  [8242, 'prime'],
90
+ [8243, 'Prime'],
85
91
  [8254, 'oline'],
86
92
  [8260, 'frasl'],
87
93
  [8472, 'weierp'],
@@ -139,6 +145,7 @@ module Kramdown
139
145
  [8855, 'otimes'],
140
146
  [8869, 'perp'],
141
147
  [8901, 'sdot'],
148
+ [8942, 'vellip'],
142
149
  [8968, 'rceil'],
143
150
  [8969, 'lceil'],
144
151
  [8970, 'lfloor'],
@@ -182,18 +189,21 @@ module Kramdown
182
189
  [165, 'yen'],
183
190
  [166, 'brvbar'],
184
191
  [167, 'sect'],
192
+ [168, 'uml'],
185
193
  [171, 'laquo'],
186
194
  [187, 'raquo'],
187
195
  [174, 'reg'],
188
196
  [170, 'ordf'],
189
197
  [172, 'not'],
190
198
  [173, 'shy'],
199
+ [175, 'macr'],
191
200
  [176, 'deg'],
192
201
  [177, 'plusmn'],
193
202
  [180, 'acute'],
194
203
  [181, 'micro'],
195
204
  [182, 'para'],
196
205
  [183, 'middot'],
206
+ [184, 'cedil'],
197
207
  [186, 'ordm'],
198
208
  [162, 'cent'],
199
209
  [185, 'sup1'],
@@ -202,6 +212,7 @@ module Kramdown
202
212
  [189, 'frac12'],
203
213
  [188, 'frac14'],
204
214
  [190, 'frac34'],
215
+ [191, 'iquest'],
205
216
  [192, 'Agrave'],
206
217
  [193, 'Aacute'],
207
218
  [194, 'Acirc'],
@@ -38,6 +38,16 @@ module Kramdown
38
38
  end
39
39
  end
40
40
 
41
+ # Sets the byte position of the scan pointer.
42
+ #
43
+ # Note: This also resets some internal variables, so always use pos= when setting the position
44
+ # and don't use any other method for that!
45
+ def pos=(pos)
46
+ super
47
+ @previous_line_number = @start_line_number
48
+ @previous_pos = 0
49
+ end
50
+
41
51
  # Returns the line number for current charpos.
42
52
  #
43
53
  # NOTE: Requires that all line endings are normalized to '\n'
@@ -10,6 +10,6 @@
10
10
  module Kramdown
11
11
 
12
12
  # The kramdown version.
13
- VERSION = '1.3.3'
13
+ VERSION = '1.4.0'
14
14
 
15
15
  end
@@ -1,4 +1,4 @@
1
- .TH "KRAMDOWN" 1 "May 2012"
1
+ .TH "KRAMDOWN" 1 "June 2014"
2
2
  .SH NAME
3
3
  kramdown \- a fast, pure-Ruby Markdown-superset converter
4
4
  .SH SYNOPSIS
@@ -9,7 +9,7 @@ kramdown \- a fast, pure-Ruby Markdown-superset converter
9
9
  kramdown is primarily used for parsing a superset of Markdown and converting it to different output
10
10
  formats. It supports standard Markdown (with some minor modifications) and various extensions like
11
11
  tables and definition lists. Due to its modular architecture it also allows other input formats than
12
- Markdown, for example, HTML.
12
+ Markdown, for example, HTML or Github Flavored Markdown.
13
13
 
14
14
  If \fIFILE\fR is not specified, kramdown reads from the standard input. The result is written to the
15
15
  standard output.
@@ -20,10 +20,10 @@ converts its input.
20
20
  .SH OPTIONS
21
21
  .TP
22
22
  .B \-i, \-\-input ARG
23
- Specify the input format. Available input formats: kramdown (this is the default) or html.
23
+ Specify the input format. Available input formats: kramdown (this is the default), markdown, GFM or html.
24
24
  .TP
25
25
  .B \-o, \-\-output ARG
26
- Specify one or more output formats separated by commas: html (default), kramdown, latex or
26
+ Specify one or more output formats separated by commas: html (default), kramdown, latex, pdf or
27
27
  remove_html_tags.
28
28
  .TP
29
29
  .B \-v, \-\-version
@@ -116,6 +116,7 @@ class TestFiles < Minitest::Test
116
116
  'test/testcases/block/12_extension/options3.text', # bc of options option
117
117
  'test/testcases/block/09_html/content_model/tables.text', # bc of parse_block_html option
118
118
  'test/testcases/block/09_html/html_to_native/header.text', # bc of auto_ids option that interferes
119
+ 'test/testcases/block/09_html/html_to_native/table_simple.text', # bc of tr style attr getting removed
119
120
  'test/testcases/block/09_html/simple.text', # bc of webgen:block elements
120
121
  'test/testcases/block/11_ial/simple.text', # bc of change of ordering of attributes in header
121
122
  'test/testcases/span/extension/comment.text', # bc of comment text modifications (can this be avoided?)
@@ -74,9 +74,11 @@ describe 'location' do
74
74
  =======
75
75
  {:.line-10}
76
76
 
77
+ ^
78
+
77
79
  header5
78
80
  -------
79
- {:.line-14}
81
+ {:.line-16}
80
82
  ),
81
83
  'horizontal_rule' => %(\na para\n\n----\n{:.line-3}\n),
82
84
  'html_entity' => "a para\n\nanother para with &amp;{:.line-3} html entity.\n",
@@ -136,7 +138,19 @@ describe 'location' do
136
138
  another para ---{:.line-3}
137
139
 
138
140
  another para ...{:.line-5}
139
- )
141
+ ),
142
+ 'gh issue 129' => %(
143
+ `|`
144
+ {:.line-1}
145
+ ),
146
+ 'gh issue 131' => %(
147
+ * {:.line-1} test
148
+ line 2
149
+ * {:.line-3} second
150
+ * {:.line-4} third
151
+ * {:.line-5} * {:.line-5} one
152
+ * {:.line-6} two
153
+ ),
140
154
  }
141
155
  test_cases.each do |name, test_string|
142
156
  it "Handles #{ name }" do
@@ -32,6 +32,19 @@
32
32
  </tfoot>
33
33
  </table>
34
34
 
35
+ <table class="examples">
36
+ <tbody>
37
+ <tr>
38
+ <td style="text-align: left">Usage</td>
39
+ <td style="width: 10em">Output</td>
40
+ </tr>
41
+ <tr>
42
+ <td style="text-align: left">Some *data*</td>
43
+ <td>Some more</td>
44
+ </tr>
45
+ </tbody>
46
+ </table>
47
+
35
48
  <table class="examples">
36
49
  <tr>
37
50
  <th>Usage</th>
@@ -40,6 +40,21 @@ locker
40
40
  </tfoot>
41
41
  </table>
42
42
 
43
+ <table class="examples">
44
+ <tr>
45
+ <td style="text-align: left">Usage</td>
46
+ <td style="width: 10em">
47
+ Output
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td style="text-align: left">Some *data*</td>
52
+ <td>
53
+ Some more
54
+ </td>
55
+ </tr>
56
+ </table>
57
+
43
58
  <table class="examples">
44
59
  <tr>
45
60
  <th>Usage</th>
@@ -0,0 +1,2 @@
1
+ <script type="math/tex; mode=display">% <![CDATA[
2
+ alert('a') alert('b<') %]]></script>
@@ -0,0 +1 @@
1
+ $$ <script>alert('a')</script> <script>alert('b<')</script> $$
@@ -25,3 +25,5 @@ This is a para.</p>
25
25
 
26
26
  <script type="math/tex; mode=display">5+5</script>
27
27
  <script type="math/tex; mode=display">5+5</script>
28
+
29
+ <script type="math/tex; mode=display">|x| = 5</script>
@@ -26,3 +26,5 @@ $$5+5$$
26
26
  ^
27
27
  $$5+5$$
28
28
  {:.cls}
29
+
30
+ $$|x| = 5$$
@@ -12,3 +12,4 @@
12
12
 
13
13
  <p>No id: <img src="other.png" alt="imgo" title="Title" /></p>
14
14
 
15
+ <p>With escaped pipe: <img src="other.png" alt="an | pipe" /></p>
@@ -14,3 +14,5 @@ No id: ![imgo]
14
14
 
15
15
  [img]: other.png
16
16
  [imgo]: other.png "Title"
17
+
18
+ With escaped pipe: ![an \| pipe](other.png)
@@ -0,0 +1,11 @@
1
+ <div class="footnotes">
2
+ <ol>
3
+ <li id="fn:1">
4
+ <p>Footnote text <a href="#fnref:1" class="reversefootnote">&#8617;</a></p>
5
+ </li>
6
+ </ol>
7
+ </div>
8
+
9
+ <p>Some para with a<sup id="fnref:1"><a href="#fn:1" class="footnote">1</a></sup> footnote.</p>
10
+
11
+ <p>And another para.</p>
@@ -0,0 +1,8 @@
1
+ * footnotes will be placed here
2
+ {:footnotes}
3
+
4
+ Some para with a[^1] footnote.
5
+
6
+ [^1]: Footnote text
7
+
8
+ And another para.
@@ -32,3 +32,10 @@ now </span>.</p>
32
32
  <p>A <script>*not*</script> tag.</p>
33
33
 
34
34
  <p>An <span>unclosed <em>tag.</em></span></p>
35
+
36
+ <p>Some <code>element with | pipe symbol</code></p>
37
+
38
+ <p>Some <span><code>element with | pipe symbol</code></span></p>
39
+
40
+ <p>Some <code>element with | pipe
41
+ symbol|</code></p>
@@ -32,3 +32,10 @@ An invalid </closing> tag.
32
32
  A <script>*not*</script> tag.
33
33
 
34
34
  An <span>unclosed *tag.*
35
+
36
+ Some <code>element with | pipe symbol</code>
37
+
38
+ Some <span><code>element with | pipe symbol</code></span>
39
+
40
+ Some <code>element with | pipe
41
+ symbol|</code>
@@ -0,0 +1,2 @@
1
+ <p>This is raw <kbd>--version</kbd> and <samp>--version</samp> and <var>--version</var> and
2
+ <code>---version</code>.</p>
@@ -0,0 +1,2 @@
1
+ This is raw <kbd>--version</kbd> and <samp>--version</samp> and <var>--version</var> and
2
+ <code>---version</code>.
@@ -0,0 +1,3 @@
1
+ <h1>header</h1>
2
+
3
+ <p>#no header</p>
@@ -0,0 +1,3 @@
1
+ # header
2
+
3
+ #no header
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -86,8 +86,6 @@ files:
86
86
  - benchmark/benchmark.rb
87
87
  - benchmark/benchmark.sh
88
88
  - benchmark/generate_data.rb
89
- - benchmark/graph-ruby-2.1.0p0-0.png
90
- - benchmark/kramdown-ruby-2.1.0p0-0.dat
91
89
  - benchmark/mdbasics.text
92
90
  - benchmark/mdsyntax.text
93
91
  - benchmark/testing.sh
@@ -413,6 +411,8 @@ files:
413
411
  - test/testcases/block/14_table/table_with_footnote.html
414
412
  - test/testcases/block/14_table/table_with_footnote.latex
415
413
  - test/testcases/block/14_table/table_with_footnote.text
414
+ - test/testcases/block/15_math/gh_128.html
415
+ - test/testcases/block/15_math/gh_128.text
416
416
  - test/testcases/block/15_math/normal.html
417
417
  - test/testcases/block/15_math/normal.text
418
418
  - test/testcases/block/16_toc/no_toc.html
@@ -471,6 +471,8 @@ files:
471
471
  - test/testcases/span/04_footnote/markers.html
472
472
  - test/testcases/span/04_footnote/markers.latex
473
473
  - test/testcases/span/04_footnote/markers.text
474
+ - test/testcases/span/04_footnote/placement.html
475
+ - test/testcases/span/04_footnote/placement.text
474
476
  - test/testcases/span/05_html/across_lines.html
475
477
  - test/testcases/span/05_html/across_lines.text
476
478
  - test/testcases/span/05_html/invalid.html
@@ -481,6 +483,8 @@ files:
481
483
  - test/testcases/span/05_html/markdown_attr.text
482
484
  - test/testcases/span/05_html/normal.html
483
485
  - test/testcases/span/05_html/normal.text
486
+ - test/testcases/span/05_html/raw_span_elements.html
487
+ - test/testcases/span/05_html/raw_span_elements.text
484
488
  - test/testcases/span/abbreviations/abbrev.html
485
489
  - test/testcases/span/abbreviations/abbrev.text
486
490
  - test/testcases/span/abbreviations/abbrev_defs.html
@@ -527,6 +531,8 @@ files:
527
531
  - test/testcases/span/text_substitutions/typography.html
528
532
  - test/testcases/span/text_substitutions/typography.options
529
533
  - test/testcases/span/text_substitutions/typography.text
534
+ - test/testcases_gfm/atx_header.html
535
+ - test/testcases_gfm/atx_header.text
530
536
  - test/testcases_gfm/backticks_disable_highlighting.html
531
537
  - test/testcases_gfm/backticks_disable_highlighting.options
532
538
  - test/testcases_gfm/backticks_disable_highlighting.text
@@ -1,9 +0,0 @@
1
- # 2014-01-20--21:04:17 || 2014-01-20--21:48:40 || 2014-01-20--22:35:48 || 2014-01-21--11:13:47 || 2014-01-21--11:21:44 || 2014-01-21--11:34:35
2
- 1 0.00756 0.00812 0.00894 0.00730 0.00781 0.00793
3
- 2 0.01485 0.01459 0.01474 0.01465 0.01471 0.01429
4
- 4 0.02822 0.02783 0.02973 0.02855 0.02746 0.02871
5
- 8 0.05997 0.05985 0.06152 0.06203 0.06018 0.06171
6
- 16 0.12721 0.12596 0.12647 0.12438 0.12664 0.12578
7
- 32 0.27359 0.27128 0.28278 0.27786 0.27565 0.27402
8
- 64 0.64162 0.63571 0.67304 0.64003 0.64986 0.63973
9
- 128 1.57056 1.53235 1.62888 1.55602 1.53303 1.53403