lib/kramdown/parser/kramdown/extensions.rb in kramdown-1.4.1 vs lib/kramdown/parser/kramdown/extensions.rb in kramdown-1.4.2
- old
+ new
@@ -52,17 +52,17 @@
end
# Parse the generic extension at the current point. The parameter +type+ can either be :block
# or :span depending whether we parse a block or span extension tag.
def parse_extension_start_tag(type)
- orig_pos = @src.pos
+ saved_pos = @src.save_pos
start_line_number = @src.current_line_number
@src.pos += @src.matched_size
error_block = lambda do |msg|
warning(msg)
- @src.pos = orig_pos
+ @src.revert_pos(saved_pos)
add_text(@src.getch) if type == :span
false
end
if @src[4] || @src.matched == '{:/}'
@@ -83,23 +83,23 @@
else
return error_block.call("No stop tag for extension '#{ext}' found on line #{start_line_number} - ignoring it")
end
end
- if !handle_extension(ext, opts, body, type)
+ if !handle_extension(ext, opts, body, type, start_line_number)
error_block.call("Invalid extension with name '#{ext}' specified on line #{start_line_number} - ignoring it")
else
true
end
end
- def handle_extension(name, opts, body, type)
+ def handle_extension(name, opts, body, type, line_no = nil)
case name
when 'comment'
- @tree.children << Element.new(:comment, body, nil, :category => type) if body.kind_of?(String)
+ @tree.children << Element.new(:comment, body, nil, :category => type, :location => line_no) if body.kind_of?(String)
true
when 'nomarkdown'
- @tree.children << Element.new(:raw, body, nil, :category => type, :type => opts['type'].to_s.split(/\s+/)) if body.kind_of?(String)
+ @tree.children << Element.new(:raw, body, nil, :category => type, :location => line_no, :type => opts['type'].to_s.split(/\s+/)) if body.kind_of?(String)
true
when 'options'
opts.select do |k,v|
k = k.to_sym
if Kramdown::Options.defined?(k)