kramdown 1.4.0 → 1.4.1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bc587193307dcea4710eed05bfa2060a518c67e
4
- data.tar.gz: 712948207deb53058cfd494b071874d1c867c309
3
+ metadata.gz: 558b4355efb3892936bc7f01dd747401964a4f2c
4
+ data.tar.gz: 4e3deeabf3bd99defba379802b3ff0007ed8cb9f
5
5
  SHA512:
6
- metadata.gz: 83c5923ed5c7d2268ef7a6a4056a8f27b52845c78eb30af5d14c42f75ac5d496e24fd5a0b8479cbf145c064de4862b46ad8194b07aca5a57b5752d4714538a54
7
- data.tar.gz: 6b49da8d9362d5f47a3181e36977c1d3d6a996b8fb062e7e496eb323f8a38604a3e14c722f75be33c671f3850178e8deb2451dbdbb1345e4ccedff82766c2362
6
+ metadata.gz: f59c155c5d6d29b2e0f74ead74808b5f6f535abe879cc8dc4cba244d76b4d5fe372916c9d6f207b86cb7a5dcee29af9731ed12553db8c12ed897c3a53f2ccd10
7
+ data.tar.gz: b18d1c60ea05561b59a37e97cd5208968cbce22cff4f4178d283a9772af7d60eaa85d3470f8f11728c2758284419af21c2f52f94fbb2882e7f291d7cb733b040
@@ -1,6 +1,6 @@
1
1
  Count Name
2
2
  ======= ====
3
- 676 Thomas Leitner <t_leitner@gmx.at>
3
+ 681 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>
@@ -12,12 +12,15 @@
12
12
  2 Nathanael Jones <nathanael.jones@gmail.com>
13
13
  2 Jo Hund <jhund@clearcove.ca>
14
14
  2 Bran <m.versum@gmail.com>
15
+ 1 utenmiki <utenmiki@gmail.com>
15
16
  1 Trevor Wennblom <trevor@well.com>
16
17
  1 tomykaira <tomykaira@gmail.com>
18
+ 1 Tim Blair <tim@bla.ir>
17
19
  1 Tim Besard <tim.besard@gmail.com>
18
20
  1 Tim Bates <tim@rumpuslabs.com>
19
21
  1 Simon Lydell <simon.lydell@gmail.com>
20
22
  1 Shusaku NAKAZATO <cu393uc@gmail.com>
23
+ 1 Sebastian Boehm <sebastian@sometimesfood.org>
21
24
  1 Postmodern <postmodern.mod3@gmail.com>
22
25
  1 Pete Michaud <michaudp@gmail.com>
23
26
  1 myqlarson <myqlarson@gmail.com>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.1
@@ -21,8 +21,8 @@ OptionParser.new do |opts|
21
21
  opts.separator "Command line options:"
22
22
  opts.separator ""
23
23
 
24
- opts.on("-i", "--input ARG", "Specify the input format: kramdown (default) or html") {|v| options[:input] = v}
25
- opts.on("-o", "--output ARG", Array, "Specify one or more output formats separated by commas: html (default), kramdown, latex or remove_html_tags") {|v| format = v}
24
+ opts.on("-i", "--input ARG", "Specify the input format: kramdown (default), html, GFM or markdown") {|v| options[:input] = v}
25
+ opts.on("-o", "--output ARG", Array, "Specify one or more output formats separated by commas: html (default), kramdown, latex, pdf or remove_html_tags") {|v| format = v}
26
26
 
27
27
  opts.on("-v", "--version", "Show the version of kramdown") do
28
28
  puts Kramdown::VERSION
@@ -1,7 +1,7 @@
1
1
  <h2>News</h2>
2
2
 
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>
3
+ <p>The latest version of kramdown is <span class="inline-important">1.4.1</span> and it was released
4
+ on <span class="inline-important">2014-08-02</span></p>
5
5
 
6
6
  <p>More <a href="{relocatable: news.html}">news</a>…</p>
7
7
 
@@ -936,7 +936,7 @@ inline math statement, you need to escape the first dollar sign:
936
936
 
937
937
  \$$ 5 + 5 $$
938
938
 
939
- If you don't even won't the inline math statement, escape the first two dollar signs:
939
+ If you don't even want the inline math statement, escape the first two dollar signs:
940
940
 
941
941
  \$\$ 5 + 5 $$
942
942
 
@@ -213,14 +213,15 @@ module Kramdown
213
213
  end
214
214
 
215
215
  def convert_img(el, opts)
216
+ line = el.options[:location]
216
217
  if el.attr['src'] =~ /^(https?|ftps?):\/\//
217
- warning("Cannot include non-local image")
218
+ warning("Cannot include non-local image#{line ? " (line #{line})" : ''}")
218
219
  ''
219
220
  elsif !el.attr['src'].empty?
220
221
  @data[:packages] << 'graphicx'
221
222
  "#{latex_link_target(el)}\\includegraphics{#{el.attr['src']}}"
222
223
  else
223
- warning("Cannot include image with empty path")
224
+ warning("Cannot include image with empty path#{line ? " (line #{line})" : ''}")
224
225
  ''
225
226
  end
226
227
  end
@@ -8,6 +8,7 @@
8
8
  #
9
9
 
10
10
  require 'prawn'
11
+ require 'prawn/table'
11
12
  require 'kramdown/utils/entities'
12
13
  require 'open-uri'
13
14
 
@@ -139,12 +140,13 @@ module Kramdown
139
140
 
140
141
  def render_standalone_image(el, opts)
141
142
  img = el.children.first
143
+ line = img.options[:location]
142
144
 
143
145
  if img.attr['src'].empty?
144
- warning("Rendering an image without a source is not possible")
146
+ warning("Rendering an image without a source is not possible#{line ? " (line #{line})" : ''}")
145
147
  return nil
146
148
  elsif img.attr['src'] !~ /\.jpe?g$|\.png$/
147
- warning("Cannot render images other than JPEG or PNG, got #{img.attr['src']}")
149
+ warning("Cannot render images other than JPEG or PNG, got #{img.attr['src']}#{line ? " on line #{line}" : ''}")
148
150
  return nil
149
151
  end
150
152
 
@@ -287,7 +289,8 @@ module Kramdown
287
289
  data << []
288
290
  row.children.each do |cell|
289
291
  if cell.children.any? {|child| child.options[:category] == :block}
290
- warning("Can't render tables with cells containing block elements")
292
+ line = el.options[:location]
293
+ warning("Can't render tables with cells containing block elements#{line ? " (line #{line})" : ''}")
291
294
  return
292
295
  end
293
296
  cell_data = inner(cell, opts)
@@ -404,7 +407,8 @@ module Kramdown
404
407
  end
405
408
 
406
409
  def render_img(el, *args) #:nodoc:
407
- warning("Rendering span images is not supported for PDF converter")
410
+ line = el.options[:location]
411
+ warning("Rendering span images is not supported for PDF converter#{line ? " (line #{line})" : ''}")
408
412
  nil
409
413
  end
410
414
 
@@ -428,7 +432,8 @@ module Kramdown
428
432
  alias_method :render_blank, :render_xml_comment
429
433
 
430
434
  def render_footnote(el, *args) #:nodoc:
431
- warning("Rendering #{el.type} not supported for PDF converter")
435
+ line = el.options[:location]
436
+ warning("Rendering #{el.type} not supported for PDF converter#{line ? " (line #{line})" : ''}")
432
437
  nil
433
438
  end
434
439
  alias_method :render_raw, :render_footnote
@@ -50,9 +50,10 @@ module Kramdown
50
50
 
51
51
  # Some HTML elements like script belong to both categories (i.e. are valid in block and
52
52
  # span HTML) and don't appear therefore!
53
+ # script, textarea
53
54
  HTML_SPAN_ELEMENTS = %w{a abbr acronym b big bdo br button cite code del dfn em i img input
54
55
  ins kbd label option q rb rbc rp rt rtc ruby samp select small span
55
- strong sub sup textarea tt var}
56
+ strong sub sup tt u var}
56
57
  HTML_BLOCK_ELEMENTS = %w{address article aside applet body button blockquote caption col colgroup dd div dl dt fieldset
57
58
  figcaption footer form h1 h2 h3 h4 h5 h6 header hgroup hr html head iframe legend menu
58
59
  li map nav ol optgroup p pre section summary table tbody td th thead tfoot tr ul}
@@ -74,17 +75,18 @@ module Kramdown
74
75
  # (first parameter is the created element; the second parameter is +true+ if the HTML
75
76
  # element is already closed, ie. contains no body; the third parameter specifies whether the
76
77
  # body - and the end tag - need to be handled in case closed=false).
77
- def handle_html_start_tag # :yields: el, closed, handle_body
78
+ def handle_html_start_tag(line = nil) # :yields: el, closed, handle_body
78
79
  name = @src[1].downcase
79
80
  closed = !@src[4].nil?
80
81
  attrs = Utils::OrderedHash.new
81
82
  @src[2].scan(HTML_ATTRIBUTE_RE).each {|attr,sep,val| attrs[attr.downcase] = val || ""}
82
83
 
83
84
  el = Element.new(:html_element, name, attrs, :category => :block)
85
+ el.options[:location] = line if line
84
86
  @tree.children << el
85
87
 
86
88
  if !closed && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
87
- warning("The HTML tag '#{el.value}' cannot have any content - auto-closing it")
89
+ warning("The HTML tag '#{el.value}' on line #{line} cannot have any content - auto-closing it")
88
90
  closed = true
89
91
  end
90
92
  if name == 'script' || name == 'style'
@@ -127,17 +129,22 @@ module Kramdown
127
129
  while !@src.eos? && !done
128
130
  if result = @src.scan_until(HTML_RAW_START)
129
131
  add_text(result, @tree, :text)
132
+ line = @src.current_line_number
130
133
  if result = @src.scan(HTML_COMMENT_RE)
131
- @tree.children << Element.new(:xml_comment, result, nil, :category => :block)
134
+ @tree.children << Element.new(:xml_comment, result, nil, :category => :block, :location => line)
132
135
  elsif result = @src.scan(HTML_INSTRUCTION_RE)
133
- @tree.children << Element.new(:xml_pi, result, nil, :category => :block)
136
+ @tree.children << Element.new(:xml_pi, result, nil, :category => :block, :location => line)
134
137
  elsif @src.scan(HTML_TAG_RE)
135
- handle_html_start_tag(&block)
138
+ if method(:handle_html_start_tag).arity == 1
139
+ handle_html_start_tag(line, &block)
140
+ else
141
+ handle_html_start_tag(&block) # DEPRECATED: method needs to accept line number in 2.0
142
+ end
136
143
  elsif @src.scan(HTML_TAG_CLOSE_RE)
137
144
  if @tree.value == @src[1].downcase
138
145
  done = true
139
146
  else
140
- warning("Found invalidly used HTML closing tag for '#{@src[1].downcase}' - ignoring it")
147
+ warning("Found invalidly used HTML closing tag for '#{@src[1].downcase}' on line #{line} - ignoring it")
141
148
  end
142
149
  else
143
150
  add_text(@src.getch, @tree, :text)
@@ -145,7 +152,7 @@ module Kramdown
145
152
  else
146
153
  add_text(@src.rest, @tree, :text)
147
154
  @src.terminate
148
- warning("Found no end tag for '#{@tree.value}' - auto-closing it") if @tree.type == :html_element
155
+ warning("Found no end tag for '#{@tree.value}' on line #{@tree.options[:location]} - auto-closing it") if @tree.type == :html_element
149
156
  done = true
150
157
  end
151
158
  end
@@ -330,6 +337,10 @@ module Kramdown
330
337
  el.children.each {|c| extract_text(c, raw)}
331
338
  end
332
339
 
340
+ def convert_textarea(el)
341
+ process_html_element(el, true, true)
342
+ end
343
+
333
344
  def convert_a(el)
334
345
  if el.attr['href']
335
346
  set_basics(el, :a)
@@ -24,7 +24,7 @@ module Kramdown
24
24
 
25
25
  el = Element.new(:footnote_def, nil, nil, :location => start_line_number)
26
26
  parse_blocks(el, @src[2].gsub(INDENT, ''))
27
- warning("Duplicate footnote name '#{@src[1]}' - overwriting") if @footnotes[@src[1]]
27
+ warning("Duplicate footnote name '#{@src[1]}' on line #{start_line_number} - overwriting") if @footnotes[@src[1]]
28
28
  (@footnotes[@src[1]] = {})[:content] = el
29
29
  @tree.children << Element.new(:eob, :footnote_def, nil, :location => start_line_number)
30
30
  true
@@ -41,7 +41,7 @@ module Kramdown
41
41
  if !closed && handle_body
42
42
  if content_model == :block
43
43
  if !parse_blocks(el)
44
- warning("Found no end tag for '#{el.value}' - auto-closing it")
44
+ warning("Found no end tag for '#{el.value}' (line #{el.options[:location]}) - auto-closing it")
45
45
  end
46
46
  elsif content_model == :span
47
47
  curpos = @src.pos
@@ -51,7 +51,7 @@ module Kramdown
51
51
  else
52
52
  add_text(@src.rest, el)
53
53
  @src.terminate
54
- warning("Found no end tag for '#{el.value}' - auto-closing it")
54
+ warning("Found no end tag for '#{el.value}' (line #{el.options[:location]}) - auto-closing it")
55
55
  end
56
56
  else
57
57
  parse_raw_html(el, &method(:handle_kramdown_html_tag))
@@ -65,18 +65,19 @@ module Kramdown
65
65
 
66
66
  # Parse the HTML at the current position as block-level HTML.
67
67
  def parse_block_html
68
+ line = @src.current_line_number
68
69
  if result = @src.scan(HTML_COMMENT_RE)
69
- @tree.children << Element.new(:xml_comment, result, nil, :category => :block)
70
+ @tree.children << Element.new(:xml_comment, result, nil, :category => :block, :location => line)
70
71
  @src.scan(TRAILING_WHITESPACE)
71
72
  true
72
73
  elsif result = @src.scan(HTML_INSTRUCTION_RE)
73
- @tree.children << Element.new(:xml_pi, result, nil, :category => :block)
74
+ @tree.children << Element.new(:xml_pi, result, nil, :category => :block, :location => line)
74
75
  @src.scan(TRAILING_WHITESPACE)
75
76
  true
76
77
  else
77
78
  if result = @src.check(/^#{OPT_SPACE}#{HTML_TAG_RE}/) && !HTML_SPAN_ELEMENTS.include?(@src[1].downcase)
78
79
  @src.pos += @src.matched_size
79
- handle_html_start_tag(&method(:handle_kramdown_html_tag))
80
+ handle_html_start_tag(line, &method(:handle_kramdown_html_tag))
80
81
  Kramdown::Parser::Html::ElementConverter.convert(@root, @tree.children.last) if @options[:html_to_native]
81
82
  true
82
83
  elsif result = @src.check(/^#{OPT_SPACE}#{HTML_TAG_CLOSE_RE}/) && !HTML_SPAN_ELEMENTS.include?(@src[1].downcase)
@@ -100,17 +101,18 @@ module Kramdown
100
101
 
101
102
  # Parse the HTML at the current position as span-level HTML.
102
103
  def parse_span_html
104
+ line = @src.current_line_number
103
105
  if result = @src.scan(HTML_COMMENT_RE)
104
- @tree.children << Element.new(:xml_comment, result, nil, :category => :span)
106
+ @tree.children << Element.new(:xml_comment, result, nil, :category => :span, :location => line)
105
107
  elsif result = @src.scan(HTML_INSTRUCTION_RE)
106
- @tree.children << Element.new(:xml_pi, result, nil, :category => :span)
108
+ @tree.children << Element.new(:xml_pi, result, nil, :category => :span, :location => line)
107
109
  elsif result = @src.scan(HTML_TAG_CLOSE_RE)
108
- warning("Found invalidly used HTML closing tag for '#{@src[1]}'")
110
+ warning("Found invalidly used HTML closing tag for '#{@src[1]}' on line #{line}")
109
111
  add_text(result)
110
112
  elsif result = @src.scan(HTML_TAG_RE)
111
113
  tag_name = @src[1].downcase
112
114
  if HTML_BLOCK_ELEMENTS.include?(tag_name)
113
- warning("Found block HTML tag '#{tag_name}' in span-level text")
115
+ warning("Found block HTML tag '#{tag_name}' in span-level text on line #{line}")
114
116
  add_text(result)
115
117
  return
116
118
  end
@@ -121,7 +123,7 @@ module Kramdown
121
123
  do_parsing = (HTML_CONTENT_MODEL[tag_name] == :raw || @tree.options[:content_model] == :raw ? false : @options[:parse_span_html])
122
124
  if val = HTML_MARKDOWN_ATTR_MAP[attrs.delete('markdown')]
123
125
  if val == :block
124
- warning("Cannot use block-level parsing in span-level HTML tag - using default mode")
126
+ warning("Cannot use block-level parsing in span-level HTML tag (line #{line}) - using default mode")
125
127
  elsif val == :span
126
128
  do_parsing = true
127
129
  elsif val == :default
@@ -131,17 +133,17 @@ module Kramdown
131
133
  end
132
134
  end
133
135
 
134
- el = Element.new(:html_element, tag_name, attrs, :category => :span,
136
+ el = Element.new(:html_element, tag_name, attrs, :category => :span, :location => line,
135
137
  :content_model => (do_parsing ? :span : :raw), :is_closed => !!@src[4])
136
138
  @tree.children << el
137
139
  stop_re = /<\/#{Regexp.escape(tag_name)}\s*>/i
138
140
  if !@src[4] && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
139
- warning("The HTML tag '#{el.value}' cannot have any content - auto-closing it")
141
+ warning("The HTML tag '#{el.value}' on line #{line} cannot have any content - auto-closing it")
140
142
  elsif !@src[4]
141
143
  if parse_spans(el, stop_re, (do_parsing ? nil : [:span_html]))
142
144
  @src.scan(stop_re)
143
145
  else
144
- warning("Found no end tag for '#{el.value}' - auto-closing it")
146
+ warning("Found no end tag for '#{el.value}' (line #{line}) - auto-closing it")
145
147
  add_text(@src.rest, el)
146
148
  @src.terminate
147
149
  end
@@ -15,7 +15,7 @@ module Kramdown
15
15
 
16
16
  # Normalize the link identifier.
17
17
  def normalize_link_id(id)
18
- id.gsub(/[\s\n]+/, ' ').downcase
18
+ id.gsub(/[\s]+/, ' ').downcase
19
19
  end
20
20
 
21
21
  LINK_DEFINITION_START = /^#{OPT_SPACE}\[([^\n\]]+)\]:[ \t]*(?:<(.*?)>|([^'"\n]*?\S[^'"\n]*?))[ \t]*?(?:\n?[ \t]*?(["'])(.+?)\4[ \t]*?)?\n/
@@ -87,7 +87,7 @@ module Kramdown
87
87
  if @link_defs.has_key?(link_id)
88
88
  add_link(el, @link_defs[link_id].first, @link_defs[link_id].last, alt_text)
89
89
  else
90
- warning("No link definition for link ID '#{link_id}' found")
90
+ warning("No link definition for link ID '#{link_id}' found on line #{start_line_number}")
91
91
  @src.pos = reset_pos
92
92
  add_text(result)
93
93
  end
@@ -140,7 +140,7 @@ module Kramdown
140
140
  add_container.call(has_footer ? :tfoot : :tbody, false) if !rows.empty?
141
141
 
142
142
  if !table.children.any? {|el| el.type == :tbody}
143
- warning("Found table without body - ignoring it")
143
+ warning("Found table without body on line #{table.options[:location]} - ignoring it")
144
144
  @src.pos = orig_pos
145
145
  return false
146
146
  end
@@ -10,6 +10,6 @@
10
10
  module Kramdown
11
11
 
12
12
  # The kramdown version.
13
- VERSION = '1.4.0'
13
+ VERSION = '1.4.1'
14
14
 
15
15
  end
@@ -0,0 +1,8 @@
1
+ <p>This is a <textarea>inline</textarea></p>
2
+
3
+ <textarea>This
4
+ is
5
+
6
+ some
7
+ text
8
+ </textarea>
@@ -0,0 +1,8 @@
1
+ This is a <textarea>inline</textarea>
2
+
3
+ <textarea>This
4
+ is
5
+
6
+ some
7
+ text
8
+ </textarea>
@@ -39,3 +39,5 @@ now </span>.</p>
39
39
 
40
40
  <p>Some <code>element with | pipe
41
41
  symbol|</code></p>
42
+
43
+ <p><u>underlined</u></p>
@@ -39,3 +39,5 @@ Some <span><code>element with | pipe symbol</code></span>
39
39
 
40
40
  Some <code>element with | pipe
41
41
  symbol|</code>
42
+
43
+ <u>underlined</u>
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.4.0
4
+ version: 1.4.1
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-06-18 00:00:00.000000000 Z
11
+ date: 2014-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -350,6 +350,8 @@ files:
350
350
  - test/testcases/block/09_html/simple.html.19
351
351
  - test/testcases/block/09_html/simple.options
352
352
  - test/testcases/block/09_html/simple.text
353
+ - test/testcases/block/09_html/textarea.html
354
+ - test/testcases/block/09_html/textarea.text
353
355
  - test/testcases/block/10_ald/simple.html
354
356
  - test/testcases/block/10_ald/simple.text
355
357
  - test/testcases/block/11_ial/auto_id_and_ial.html