Skip to content

Commit

Permalink
Work around REXML bug https://bugs.ruby-lang.org/issues/9277 that dis…
Browse files Browse the repository at this point in the history
…allows multiple dashes in comments. Fixes #115
  • Loading branch information
bhollis committed Dec 21, 2013
1 parent 1911554 commit f0070ab
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
5 changes: 3 additions & 2 deletions lib/maruku/input/html_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions spec/block_docs/issue115.md
Original file line number Diff line number Diff line change
@@ -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: ***
<!--
Header
------
-->

<!-- -- -->
*** Output of inspect ***
md_el(:document,[md_html("<!--\nHeader\n-\n-->"), md_html("<!-- - -->")])
*** Output of to_html ***
<!--
Header
-
-->

<!-- - -->
32 changes: 32 additions & 0 deletions spec/block_docs/xml_comments.md
Original file line number Diff line number Diff line change
@@ -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: ***
<!--
&rsquo;
-->

<!-- declarations for <head> & <body> -->

<!-- -- is invalid -->

<!-- -- is
invalid -->

*** Output of inspect ***
md_el(:document,[md_html("<!--\n&rsquo;\n-->"),
md_html("<!-- declarations for <head> & <body> -->"),
md_html("<!-- - is invalid -->"),
md_html("<!-- - is\ninvalid -->")])
*** Output of to_html ***
<!--
&rsquo;
-->

<!-- declarations for <head> & <body> -->

<!-- - is invalid -->

<!-- - is
invalid -->
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require 'json'
require 'simplecov'
SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))

0 comments on commit f0070ab

Please sign in to comment.