motion-kramdown 0.6.0 → 1.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +6 -2
  3. data/lib/kramdown.rb +1 -1
  4. data/lib/kramdown/converter.rb +10 -11
  5. data/lib/kramdown/converter/base.rb +19 -12
  6. data/lib/kramdown/converter/hash_ast.rb +38 -0
  7. data/lib/kramdown/converter/html.rb +71 -39
  8. data/lib/kramdown/converter/kramdown.rb +19 -10
  9. data/lib/kramdown/converter/latex.rb +28 -10
  10. data/lib/kramdown/converter/man.rb +303 -0
  11. data/lib/kramdown/converter/math_engine/itex2mml.rb +2 -2
  12. data/lib/kramdown/converter/math_engine/mathjax.rb +13 -3
  13. data/lib/kramdown/converter/math_engine/mathjaxnode.rb +56 -0
  14. data/lib/kramdown/converter/math_engine/ritex.rb +2 -2
  15. data/lib/kramdown/converter/math_engine/sskatex.rb +97 -0
  16. data/lib/kramdown/converter/pdf.rb +6 -6
  17. data/lib/kramdown/converter/remove_html_tags.rb +5 -3
  18. data/lib/kramdown/converter/syntax_highlighter.rb +5 -2
  19. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +8 -5
  20. data/lib/kramdown/converter/syntax_highlighter/minted.rb +35 -0
  21. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +48 -10
  22. data/lib/kramdown/converter/toc.rb +2 -2
  23. data/lib/kramdown/document.rb +16 -19
  24. data/lib/kramdown/element.rb +5 -1
  25. data/lib/kramdown/error.rb +1 -1
  26. data/lib/kramdown/options.rb +103 -7
  27. data/lib/kramdown/parser.rb +1 -1
  28. data/lib/kramdown/parser/base.rb +12 -18
  29. data/lib/kramdown/parser/gfm.rb +142 -11
  30. data/lib/kramdown/parser/html.rb +28 -18
  31. data/lib/kramdown/parser/kramdown.rb +45 -36
  32. data/lib/kramdown/parser/kramdown/abbreviation.rb +1 -1
  33. data/lib/kramdown/parser/kramdown/autolink.rb +2 -8
  34. data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
  35. data/lib/kramdown/parser/kramdown/block_boundary.rb +4 -4
  36. data/lib/kramdown/parser/kramdown/blockquote.rb +4 -4
  37. data/lib/kramdown/parser/kramdown/codeblock.rb +11 -8
  38. data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
  39. data/lib/kramdown/parser/kramdown/emphasis.rb +2 -2
  40. data/lib/kramdown/parser/kramdown/eob.rb +1 -1
  41. data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
  42. data/lib/kramdown/parser/kramdown/extensions.rb +6 -3
  43. data/lib/kramdown/parser/kramdown/footnote.rb +4 -5
  44. data/lib/kramdown/parser/kramdown/header.rb +2 -2
  45. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
  46. data/lib/kramdown/parser/kramdown/html.rb +8 -8
  47. data/lib/kramdown/parser/kramdown/html_entity.rb +2 -2
  48. data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
  49. data/lib/kramdown/parser/kramdown/link.rb +5 -4
  50. data/lib/kramdown/parser/kramdown/list.rb +17 -10
  51. data/lib/kramdown/parser/kramdown/math.rb +2 -2
  52. data/lib/kramdown/parser/kramdown/paragraph.rb +19 -8
  53. data/lib/kramdown/parser/kramdown/smart_quotes.rb +3 -3
  54. data/lib/kramdown/parser/kramdown/table.rb +10 -12
  55. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
  56. data/lib/kramdown/parser/markdown.rb +2 -2
  57. data/lib/kramdown/utils.rb +2 -1
  58. data/lib/kramdown/utils/configurable.rb +2 -2
  59. data/lib/kramdown/utils/entities.rb +1 -1
  60. data/lib/kramdown/utils/html.rb +2 -2
  61. data/lib/kramdown/utils/lru_cache.rb +40 -0
  62. data/lib/kramdown/utils/ordered_hash.rb +2 -71
  63. data/lib/kramdown/utils/string_scanner.rb +2 -2
  64. data/lib/kramdown/utils/unidecoder.rb +2 -2
  65. data/lib/kramdown/version.rb +2 -2
  66. data/lib/rubymotion/require_override.rb +9 -0
  67. data/lib/rubymotion/version.rb +1 -1
  68. data/spec/{helpers → motion-kramdown/_helpers}/it_behaves_like.rb +0 -0
  69. data/spec/{helpers → motion-kramdown/_helpers}/option_file.rb +2 -2
  70. data/spec/{helpers → motion-kramdown/_helpers}/tidy.rb +0 -0
  71. data/spec/motion-kramdown/bench_mark.rb +37 -0
  72. data/spec/{document_tree.rb → motion-kramdown/document_tree.rb} +11 -1
  73. data/spec/{gfm_to_html.rb → motion-kramdown/gfm_to_html.rb} +51 -18
  74. data/spec/{html_to_html.rb → motion-kramdown/html_to_html.rb} +27 -9
  75. data/spec/{html_to_kramdown_to_html.rb → motion-kramdown/html_to_kramdown_to_html.rb} +35 -16
  76. data/spec/motion-kramdown/kramdown_to_xxx.rb +75 -0
  77. data/spec/{test_location.rb → motion-kramdown/test_location.rb} +0 -0
  78. data/spec/{test_string_scanner_kramdown.rb → motion-kramdown/test_string_scanner_kramdown.rb} +0 -0
  79. data/spec/motion-kramdown/text_manpage.rb +11 -0
  80. data/spec/{text_to_kramdown_to_html.rb → motion-kramdown/text_to_kramdown_to_html.rb} +30 -19
  81. data/spec/{text_to_latex.rb → motion-kramdown/text_to_latex.rb} +0 -0
  82. data/spec/{helpers/spec_options.rb → spec_helper.rb} +13 -2
  83. metadata +54 -33
  84. data/lib/kramdown/compatibility.rb +0 -36
  85. data/spec/bench_mark.rb +0 -43
  86. data/spec/kramdown_to_xxx.rb +0 -42
@@ -1,15 +1,15 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/extensions'
11
- # RM require 'kramdown/parser/kramdown/blank_line'
12
- # RM require 'kramdown/parser/kramdown/codeblock'
10
+ require 'kramdown/parser/kramdown/extensions'
11
+ require 'kramdown/parser/kramdown/blank_line'
12
+ require 'kramdown/parser/kramdown/codeblock'
13
13
 
14
14
  module Kramdown
15
15
  module Parser
@@ -61,4 +61,3 @@ module Kramdown
61
61
  end
62
62
  end
63
63
  end
64
-
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/block_boundary'
10
+ require 'kramdown/parser/kramdown/block_boundary'
11
11
 
12
12
  module Kramdown
13
13
  module Parser
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/html'
10
+ require 'kramdown/parser/html'
11
11
 
12
12
  module Kramdown
13
13
  module Parser
@@ -113,14 +113,15 @@ module Kramdown
113
113
  warning("Found invalidly used HTML closing tag for '#{@src[1]}' on line #{line}")
114
114
  add_text(result)
115
115
  elsif result = @src.scan(HTML_TAG_RE)
116
- tag_name = @src[1].downcase
116
+ tag_name = @src[1]
117
+ tag_name.downcase! if HTML_ELEMENT[tag_name.downcase]
117
118
  if HTML_BLOCK_ELEMENTS.include?(tag_name)
118
119
  warning("Found block HTML tag '#{tag_name}' in span-level text on line #{line}")
119
120
  add_text(result)
120
121
  return
121
122
  end
122
123
 
123
- attrs = parse_html_attributes(@src[2], line)
124
+ attrs = parse_html_attributes(@src[2], line, HTML_ELEMENT[tag_name])
124
125
  attrs.each {|name, value| value.gsub!(/\n+/, ' ')}
125
126
 
126
127
  do_parsing = (HTML_CONTENT_MODEL[tag_name] == :raw || @tree.options[:content_model] == :raw ? false : @options[:parse_span_html])
@@ -139,10 +140,9 @@ module Kramdown
139
140
  el = Element.new(:html_element, tag_name, attrs, :category => :span, :location => line,
140
141
  :content_model => (do_parsing ? :span : :raw), :is_closed => !!@src[4])
141
142
  @tree.children << el
142
- stop_re = /<\/#{Regexp.escape(tag_name)}\s*>/i
143
- if !@src[4] && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
144
- warning("The HTML tag '#{el.value}' on line #{line} cannot have any content - auto-closing it")
145
- elsif !@src[4]
143
+ stop_re = /<\/#{Regexp.escape(tag_name)}\s*>/
144
+ stop_re = Regexp.new(stop_re.source, Regexp::IGNORECASE) if HTML_ELEMENT[tag_name]
145
+ if !@src[4] && !HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
146
146
  if parse_spans(el, stop_re, (do_parsing ? nil : [:span_html]))
147
147
  @src.scan(stop_re)
148
148
  else
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/html'
10
+ require 'kramdown/parser/html'
11
11
 
12
12
  module Kramdown
13
13
  module Parser
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/escaped_chars'
10
+ require 'kramdown/parser/kramdown/escaped_chars'
11
11
 
12
12
  module Kramdown
13
13
  module Parser
@@ -18,10 +18,11 @@ module Kramdown
18
18
  id.gsub(/[\s]+/, ' ').downcase
19
19
  end
20
20
 
21
- LINK_DEFINITION_START = /^#{OPT_SPACE}\[([^\n\]]+)\]:[ \t]*(?:<(.*?)>|([^'"\n]*?\S[^'"\n]*?))[ \t]*?(?:\n?[ \t]*?(["'])(.+?)\4[ \t]*?)?\n/
21
+ LINK_DEFINITION_START = /^#{OPT_SPACE}\[([^\n\]]+)\]:[ \t]*(?:<(.*?)>|([^\n]*?\S[^\n]*?))(?:(?:[ \t]*?\n|[ \t]+?)[ \t]*?(["'])(.+?)\4)?[ \t]*?\n/
22
22
 
23
23
  # Parse the link definition at the current location.
24
24
  def parse_link_definition
25
+ return false if @src[3].to_s =~ /[ \t]+["']/
25
26
  @src.pos += @src.matched_size
26
27
  link_id, link_url, link_title = normalize_link_id(@src[1]), @src[2] || @src[3], @src[5]
27
28
  warning("Duplicate link ID '#{link_id}' on line #{@src.current_line_number} - overwriting") if @link_defs[link_id]
@@ -76,7 +77,7 @@ module Kramdown
76
77
  count = count + (@src[1] ? -1 : 1)
77
78
  count - el.children.select {|c| c.type == :img}.size == 0
78
79
  end
79
- if !found || (link_type == :a && el.children.empty?)
80
+ unless found
80
81
  @src.revert_pos(saved_pos)
81
82
  add_text(result)
82
83
  return
@@ -1,16 +1,16 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/blank_line'
11
- # RM require 'kramdown/parser/kramdown/eob'
12
- # RM require 'kramdown/parser/kramdown/horizontal_rule'
13
- # RM require 'kramdown/parser/kramdown/extensions'
10
+ require 'kramdown/parser/kramdown/blank_line'
11
+ require 'kramdown/parser/kramdown/eob'
12
+ require 'kramdown/parser/kramdown/horizontal_rule'
13
+ require 'kramdown/parser/kramdown/extensions'
14
14
 
15
15
  module Kramdown
16
16
  module Parser
@@ -39,7 +39,7 @@ module Kramdown
39
39
  end
40
40
  indentation += content[/^ */].length
41
41
  end
42
- content = content.sub(/^\s*/, '')
42
+ content.sub!(/^\s*/, '')
43
43
 
44
44
  # [content, indentation, *PARSE_FIRST_LIST_LINE_REGEXP_CACHE[indentation]] # RM use caching code below
45
45
 
@@ -90,7 +90,7 @@ module Kramdown
90
90
  list.children << item
91
91
 
92
92
  #------------------------------------------------------------------------------
93
- # RM don't know why, but using the item.options[:ial] directly in the block
93
+ # RM don't know why, but using the item.options[:ial] directly in the block
94
94
  # caused an object to be autoreleased one too many times in RubyMotion,
95
95
  # crashing the app. So use this workaround
96
96
  item_options = (item.options[:ial] ||= {}) # RM
@@ -107,10 +107,12 @@ module Kramdown
107
107
  item.value = [item.value]
108
108
  elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re)))
109
109
  result.sub!(/^(\t+)/) { " " * 4 * $1.length }
110
- result.sub!(indent_re, '')
111
- if !nested_list_found && result =~ LIST_START
110
+ indentation_found = result.sub!(indent_re, '')
111
+ if !nested_list_found && indentation_found && result =~ LIST_START
112
112
  item.value << ''
113
113
  nested_list_found = true
114
+ elsif nested_list_found && !indentation_found && result =~ LIST_START
115
+ result = " " * (indentation + 4) << result
114
116
  end
115
117
  item.value.last << result
116
118
  last_is_blank = false
@@ -189,6 +191,11 @@ module Kramdown
189
191
  deflist.options[:location] = para.options[:location] # take location from preceding para which is the first definition term
190
192
  para.children.first.value.split(/\n/).each do |term|
191
193
  el = Element.new(:dt, nil, nil, :location => @src.current_line_number)
194
+ term.sub!(self.class::LIST_ITEM_IAL) do
195
+ parse_attribute_list($1, el.options[:ial] ||= {})
196
+ ''
197
+ end
198
+ el.options[:raw_text] = term
192
199
  el.children << Element.new(:raw_text, term)
193
200
  deflist.children << el
194
201
  end
@@ -207,7 +214,7 @@ module Kramdown
207
214
  deflist.children << item
208
215
 
209
216
  #------------------------------------------------------------------------------
210
- # RM don't know why, but using the item.options[:ial] directly in the block
217
+ # RM don't know why, but using the item.options[:ial] directly in the block
211
218
  # caused an object to be autoreleased one too many times in RubyMotion,
212
219
  # crashing the app. So use this workaround
213
220
  item_options = (item.options[:ial] ||= {}) # RM
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/block_boundary'
10
+ require 'kramdown/parser/kramdown/block_boundary'
11
11
 
12
12
  module Kramdown
13
13
  module Parser
@@ -1,17 +1,17 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/blank_line'
11
- # RM require 'kramdown/parser/kramdown/extensions'
12
- # RM require 'kramdown/parser/kramdown/eob'
13
- # RM require 'kramdown/parser/kramdown/list'
14
- # RM require 'kramdown/parser/kramdown/html'
10
+ require 'kramdown/parser/kramdown/blank_line'
11
+ require 'kramdown/parser/kramdown/extensions'
12
+ require 'kramdown/parser/kramdown/eob'
13
+ require 'kramdown/parser/kramdown/list'
14
+ require 'kramdown/parser/kramdown/html'
15
15
 
16
16
  module Kramdown
17
17
  module Parser
@@ -32,14 +32,21 @@ module Kramdown
32
32
 
33
33
  # Parse the paragraph at the current location.
34
34
  def parse_paragraph
35
+ pos = @src.pos
35
36
  start_line_number = @src.current_line_number
36
37
  result = @src.scan(PARAGRAPH_MATCH)
37
- while !@src.match?(self.class::PARAGRAPH_END)
38
+ while !@src.match?(paragraph_end)
38
39
  result << @src.scan(PARAGRAPH_MATCH)
39
40
  end
40
41
  result.rstrip!
41
42
  if @tree.children.last && @tree.children.last.type == :p
42
- @tree.children.last.children.first.value << "\n" << result
43
+ last_item_in_para = @tree.children.last.children.last
44
+ if last_item_in_para && last_item_in_para.type == @text_type
45
+ joiner = (extract_string((pos - 3)...pos, @src) == " \n" ? " \n" : "\n")
46
+ last_item_in_para.value << joiner << result
47
+ else
48
+ add_text(result, @tree.children.last)
49
+ end
43
50
  else
44
51
  @tree.children << new_block_el(:p, nil, nil, :location => start_line_number)
45
52
  result.lstrip!
@@ -49,6 +56,10 @@ module Kramdown
49
56
  end
50
57
  define_parser(:paragraph, PARAGRAPH_START)
51
58
 
59
+ def paragraph_end
60
+ self.class::PARAGRAPH_END
61
+ end
62
+
52
63
  end
53
64
  end
54
65
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -123,7 +123,7 @@ module Kramdown
123
123
 
124
124
  SQ_RULES = [
125
125
  [/("|')(?=[_*]{1,2}\S)/, [:lquote1]],
126
- [/("|')(?=#{SQ_PUNCT}\B)/, [:rquote1]],
126
+ [/("|')(?=#{SQ_PUNCT}(?!\.\.)\B)/, [:rquote1]],
127
127
  # Special case for double sets of quotes, e.g.:
128
128
  # <p>He said, "'Quoted' words in a larger quote."</p>
129
129
  [/(\s?)"'(?=\w)/, [1, :ldquo, :lsquo]],
@@ -136,7 +136,7 @@ module Kramdown
136
136
  # Single/double closing quotes:
137
137
  [/(#{SQ_CLOSE})('|")/, [1, :rquote2]],
138
138
  # Special case for e.g. "<i>Custer</i>'s Last Stand."
139
- [/("|')(\s|s\b|$)/, [:rquote1, 2]],
139
+ [/("|')(?=\s|s\b|$)/, [:rquote1]],
140
140
  # Any remaining single quotes should be opening ones:
141
141
  [/(.?)'/m, [1, :lsquo]],
142
142
  [/(.?)"/m, [1, :ldquo]],
@@ -1,21 +1,21 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser/kramdown/block_boundary'
10
+ require 'kramdown/parser/kramdown/block_boundary'
11
11
 
12
12
  module Kramdown
13
13
  module Parser
14
14
  class Kramdown
15
15
 
16
- TABLE_SEP_LINE = /^([+|: -]*?-[+|: -]*?)[ \t]*\n/
17
- TABLE_HSEP_ALIGN = /[ ]?(:?)-+(:?)[ ]?/
18
- TABLE_FSEP_LINE = /^[+|: =]*?=[+|: =]*?[ \t]*\n/
16
+ TABLE_SEP_LINE = /^([+|: \t-]*?-[+|: \t-]*?)[ \t]*\n/
17
+ TABLE_HSEP_ALIGN = /[ \t]?(:?)-+(:?)[ \t]?/
18
+ TABLE_FSEP_LINE = /^[+|: \t=]*?=[+|: \t=]*?[ \t]*\n/
19
19
  TABLE_ROW_LINE = /^(.*?)[ \t]*\n/
20
20
  TABLE_PIPE_CHECK = /(?:\||.*?[^\\\n]\|)/
21
21
  TABLE_LINE = /#{TABLE_PIPE_CHECK}.*?\n/
@@ -45,8 +45,10 @@ module Kramdown
45
45
 
46
46
  while !@src.eos?
47
47
  break if !@src.check(TABLE_LINE)
48
- if @src.scan(TABLE_SEP_LINE) && !rows.empty?
49
- if table.options[:alignment].empty? && !has_footer
48
+ if @src.scan(TABLE_SEP_LINE)
49
+ if rows.empty?
50
+ # nothing to do, ignoring multiple consecutive separator lines
51
+ elsif table.options[:alignment].empty? && !has_footer
50
52
  add_container.call(:thead, false)
51
53
  table.options[:alignment] = @src[1].scan(TABLE_HSEP_ALIGN).map do |left, right|
52
54
  (left.empty? && right.empty? && :default) || (right.empty? && :left) || (left.empty? && :right) || :center
@@ -73,11 +75,7 @@ module Kramdown
73
75
 
74
76
  root.children.each do |c|
75
77
  if c.type == :raw_text
76
- # Only on Ruby 1.9: f, *l = c.value.split(/(?<!\\)\|/).map {|t| t.gsub(/\\\|/, '|')}
77
- f, *l = c.value.split(/\\\|/, -1).map {|t| t.split(/\|/, -1)}.inject([]) do |memo, t|
78
- memo.last << "|#{t.shift}" if memo.size > 0
79
- memo.concat(t)
80
- end
78
+ f, *l = c.value.split(/(?<!\\)\|/, -1).map {|t| t.gsub(/\\\|/, '|')}
81
79
  (cells.empty? ? cells : cells.last) << f
82
80
  cells.concat(l)
83
81
  else
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -1,13 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 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
- # RM require 'kramdown/parser'
10
+ require 'kramdown/parser'
11
11
 
12
12
  module Kramdown
13
13
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -21,6 +21,7 @@ module Kramdown
21
21
  # RM autoload :Unidecoder, 'kramdown/utils/unidecoder'
22
22
  # RM autoload :StringScanner, 'kramdown/utils/string_scanner'
23
23
  # RM autoload :Configurable, 'kramdown/utils/configurable'
24
+ # RM autoload :LRUCache, 'kramdown/utils/lru_cache'
24
25
 
25
26
  # Treat +name+ as if it were snake cased (e.g. snake_case) and camelize it (e.g. SnakeCase).
26
27
  def self.camelize(name)
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
4
+ # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
@@ -29,7 +29,7 @@ module Kramdown
29
29
  singleton_class = (class << self; self; end)
30
30
  singleton_class.send(:define_method, :configurables) do
31
31
  @_configurables ||= Hash.new {|h, k| h[k] = {}}
32
- end
32
+ end unless respond_to?(:configurables)
33
33
  singleton_class.send(:define_method, name) do |data|
34
34
  configurables[name][data]
35
35
  end