diff --git a/vendor/plugins/maruku/lib/maruku/helpers.rb b/vendor/plugins/maruku/lib/maruku/helpers.rb index 3b382182..052810d3 100644 --- a/vendor/plugins/maruku/lib/maruku/helpers.rb +++ b/vendor/plugins/maruku/lib/maruku/helpers.rb @@ -91,9 +91,8 @@ module Helpers raw_html = "#{raw_html}" e.instance_variable_set :@parsed_html, REXML::Document.new(raw_html) - rescue + rescue #Exception => ex e.instance_variable_set :@parsed_html, nil - # tell_user "Malformed block of HTML:\n"+ # add_tabs(raw_html,1,'|') # " #{raw_html.inspect}\n\n"+ex.inspect diff --git a/vendor/plugins/maruku/lib/maruku/input/html_helper.rb b/vendor/plugins/maruku/lib/maruku/input/html_helper.rb index 84932c60..c2f5a8e0 100644 --- a/vendor/plugins/maruku/lib/maruku/input/html_helper.rb +++ b/vendor/plugins/maruku/lib/maruku/input/html_helper.rb @@ -34,10 +34,14 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser EverythingElse = %r{^[^<]+}m CommentStart = %r{^} - TO_SANITIZE = ['img','hr'] + TO_SANITIZE = ['img','hr','br'] attr_reader :rest + def my_debug(s) +# puts "---"*10+"\n"+inspect+"\t>>>\t"s + end + def initialize @rest = "" @tag_stack = [] @@ -46,7 +50,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser self.state = :inside_element end - attr_accessor :state # :inside_element, :inside_tag, :inside_comment, + attr_accessor :state # = :inside_element, :inside_tag, :inside_comment, def eat_this(line) @rest = line + @rest @@ -70,15 +74,18 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser @rest = @m.post_match self.state = :inside_comment elsif @m = Tag.match(@rest) then + my_debug "#{@state}: Tag: #{@m.to_s.inspect}" things_read += 1 handle_tag self.state = :inside_element elsif @m = PartialTag.match(@rest) then + my_debug "#{@state}: PartialTag: #{@m.to_s.inspect}" @already += @m.pre_match @rest = @m.post_match @partial_tag = @m.to_s self.state = :inside_tag elsif @m = EverythingElse.match(@rest) + my_debug "#{@state}: Everything: #{@m.to_s.inspect}" @already += @m.pre_match + @m.to_s @rest = @m.post_match self.state = :inside_element @@ -87,7 +94,9 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser end when :inside_tag if @m = /^[^>]*>/.match(@rest) then + my_debug "#{@state}: inside_tag: matched #{@m.to_s.inspect}" @partial_tag += @m.to_s + my_debug "#{@state}: inside_tag: matched TOTAL: #{@partial_tag.to_s.inspect}" @rest = @partial_tag + @m.post_match @partial_tag = nil self.state = :inside_element @@ -112,16 +121,16 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser is_closing = !!@m[1] tag = @m[2] - attributes = @m[3] - + attributes = @m[3].to_s is_single = false - if attributes =~ /\A(.*)\/\Z/ - attributes = $1 + if attributes[-1] == ?/ # =~ /\A(.*)\/\Z/ + attributes = attributes[0, attributes.size-1] is_single = true end -# puts "READ TAG #{@m.to_s.inspect} tag = #{tag} closing? #{is_closing} single = #{is_single}" + my_debug "Attributes: #{attributes.inspect}" + my_debug "READ TAG #{@m.to_s.inspect} tag = #{tag} closing? #{is_closing} single = #{is_single}" if TO_SANITIZE.include? tag attributes.strip! @@ -145,7 +154,10 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser else @already += @m.to_s - @tag_stack.push(tag) unless is_single + if not is_single + @tag_stack.push(tag) + my_debug "Pushing #{tag.inspect} when read #{@m.to_s.inspect}" + end end end def error(s) @@ -167,6 +179,8 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser @already end + def rest() @rest end + def is_finished? (self.state == :inside_element) and @tag_stack.empty? end diff --git a/vendor/plugins/maruku/lib/maruku/input/parse_block.rb b/vendor/plugins/maruku/lib/maruku/input/parse_block.rb index f722be79..d9a58a4f 100644 --- a/vendor/plugins/maruku/lib/maruku/input/parse_block.rb +++ b/vendor/plugins/maruku/lib/maruku/input/parse_block.rb @@ -237,6 +237,10 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser ex = e.inspect + e.backtrace.join("\n") maruku_error "Bad block-level HTML:\n#{add_tabs(ex,1,'|')}\n", src end + if not (h.rest =~ /^\s*$/) + maruku_error "Could you please format this better?\n"+ + "I see that #{h.rest.inspect} is left after the raw HTML.", src + end raw_html = h.stuff_you_read return md_html(raw_html) end @@ -246,7 +250,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser while src.cur_line # :olist does not break case t = src.cur_line.md_type - when :quote,:header3,:empty,:raw_html,:ref_definition,:ial,:xml_instr + when :quote,:header3,:empty,:ref_definition,:ial #,:xml_instr,:raw_html break when :olist,:ulist break if src.next_line.md_type == t @@ -349,6 +353,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser # collect all indented lines saw_empty = false; saw_anything_after = false while src.cur_line +# puts "Reading indent = #{indentation} #{src.cur_line.inspect}" #puts "#{src.cur_line.md_type} #{src.cur_line.inspect}" if src.cur_line.md_type == :empty saw_empty = true @@ -365,7 +370,9 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser end saw_anything_after = true else - break if break_list.include? src.cur_line.md_type +# if src.cur_line[0] != ?\ + break if break_list.include? src.cur_line.md_type +# end # break if src.cur_line.md_type != :text end diff --git a/vendor/plugins/maruku/lib/maruku/input/parse_span_better.rb b/vendor/plugins/maruku/lib/maruku/input/parse_span_better.rb index 2e1bbf51..edfc9e55 100644 --- a/vendor/plugins/maruku/lib/maruku/input/parse_span_better.rb +++ b/vendor/plugins/maruku/lib/maruku/input/parse_span_better.rb @@ -451,22 +451,35 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser h = HTMLHelper.new begin # This is our current buffer in the context - start = src.current_remaining_buffer + next_stuff = src.current_remaining_buffer - h.eat_this start - if not h.is_finished? - error "inline_html: Malformed:\n "+ - "#{start.inspect}\n #{h.inspect}",src,con + consumed = 0 + while true + h.eat_this next_stuff[consumed].chr; consumed += 1 + break if h.is_finished? + + if consumed >= next_stuff.size + maruku_error "Malformed HTML starting at #{next_stuff.inspect}", src, con + end end + src.ignore_chars(consumed) + con.push_element md_html(h.stuff_you_read) - consumed = start.size - h.rest.size - if consumed > 0 - con.push_element md_html(h.stuff_you_read) - src.ignore_chars(consumed) - else - puts "HTML helper did not work on #{start.inspect}" - con.push_char src.shift_char - end + #start = src.current_remaining_buffer + # h.eat_this start + # if not h.is_finished? + # error "inline_html: Malformed:\n "+ + # "#{start.inspect}\n #{h.inspect}",src,con + # end + # + # consumed = start.size - h.rest.size + # if consumed > 0 + # con.push_element md_html(h.stuff_you_read) + # src.ignore_chars(consumed) + # else + # puts "HTML helper did not work on #{start.inspect}" + # con.push_char src.shift_char + # end rescue Exception => e maruku_error "Bad html: \n" + add_tabs(e.inspect+e.backtrace.join("\n"),1,'>'), diff --git a/vendor/plugins/maruku/lib/maruku/input/type_detection.rb b/vendor/plugins/maruku/lib/maruku/input/type_detection.rb index ef9c4277..17a598f6 100644 --- a/vendor/plugins/maruku/lib/maruku/input/type_detection.rb +++ b/vendor/plugins/maruku/lib/maruku/input/type_detection.rb @@ -50,8 +50,11 @@ module MaRuKu; module Strings return :xml_instr if l =~ %r{^\s*<\?} return :raw_html if l =~ %r{^[ ]?[ ]?[ ]?/ -end end \ No newline at end of file +end end diff --git a/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb b/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb index 7a870ade..bd055a20 100644 --- a/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb +++ b/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb @@ -42,7 +42,7 @@ module MaRuKu dummy_layout_slide = "
-
+