From f0070ab35eff4b08b1c9deab1d18ccf3251e9c48 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 21 Dec 2013 15:07:30 -0800 Subject: [PATCH] Work around REXML bug https://bugs.ruby-lang.org/issues/9277 that disallows multiple dashes in comments. Fixes #115 --- CHANGELOG.md | 1 + lib/maruku/input/html_helper.rb | 5 +++-- spec/block_docs/issue115.md | 20 ++++++++++++++++++++ spec/block_docs/xml_comments.md | 32 ++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 1 + 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 spec/block_docs/issue115.md create mode 100644 spec/block_docs/xml_comments.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0929a..7b87428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Properly handle empty code blocks (``). #108 * No longer print a warning when headers have entities in them. #113 * Remove non-printable control characters when sanitizing text. +* Work around REXML bug https://bugs.ruby-lang.org/issues/9277 that disallows multiple dashes in comments. #115 0.7.0 ----- diff --git a/lib/maruku/input/html_helper.rb b/lib/maruku/input/html_helper.rb index 5abac53..5e832cf 100644 --- a/lib/maruku/input/html_helper.rb +++ b/lib/maruku/input/html_helper.rb @@ -36,11 +36,12 @@ def eat_this(line) when :inside_comment if @m = CommentEnd.match(@rest) my_debug "#{@state}: Comment End: #{@m.to_s.inspect}" - @already << @m.pre_match << @m.to_s + # Workaround for https://bugs.ruby-lang.org/issues/9277 + @already << @m.pre_match.gsub(/-{2,}/, '-') << @m.to_s @rest = @m.post_match self.state = :inside_element else - @already << @rest + @already << @rest.gsub(/-{2,}/, '-') # Workaround for https://bugs.ruby-lang.org/issues/9277 @rest = "" self.state = :inside_comment end diff --git a/spec/block_docs/issue115.md b/spec/block_docs/issue115.md new file mode 100644 index 0000000..0c7f9cc --- /dev/null +++ b/spec/block_docs/issue115.md @@ -0,0 +1,20 @@ +Markdown in comments should not be parsed. https://github.com/bhollis/maruku/issues/115 +Note that output is kind of weird because we modify the comment in order to let REXML parse it due to https://bugs.ruby-lang.org/issues/9277. +*** Parameters: *** +{} +*** Markdown input: *** + + + +*** Output of inspect *** +md_el(:document,[md_html(""), md_html("")]) +*** Output of to_html *** + + + diff --git a/spec/block_docs/xml_comments.md b/spec/block_docs/xml_comments.md new file mode 100644 index 0000000..e48bb31 --- /dev/null +++ b/spec/block_docs/xml_comments.md @@ -0,0 +1,32 @@ +XML Comments need to be handled properly. +Note that output is kind of weird because we modify the comment in order to let REXML parse it due to https://bugs.ruby-lang.org/issues/9277. +*** Parameters: *** +{} +*** Markdown input: *** + + + + + + + + +*** Output of inspect *** +md_el(:document,[md_html(""), + md_html(""), + md_html(""), + md_html("")]) +*** Output of to_html *** + + + + + + + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index be560c4..a4f1de4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,2 +1,3 @@ +require 'json' require 'simplecov' SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))