diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index 3dcb762603..2b1216ef2a 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -379,11 +379,12 @@ def list_end_for(list_type) end ## - # Returns true if Ripper is available it can create a sexp from +text+ + # Returns true if text is valid ruby syntax def parseable? text - text =~ /\b(def|class|module|require) |=>|\{\s?\||do \|/ and - text !~ /<%|%>/ + eval("BEGIN {return true}\n#{text}") + rescue SyntaxError + false end ## diff --git a/test/test_rdoc_markup_to_html.rb b/test/test_rdoc_markup_to_html.rb index 3f5070dbd5..1e4b84fe9e 100644 --- a/test/test_rdoc_markup_to_html.rb +++ b/test/test_rdoc_markup_to_html.rb @@ -292,7 +292,7 @@ def accept_rule end def accept_verbatim - assert_equal "\n
hi\n world\n", @to.res.join + assert_equal "\n
hi\n world\n\n", @to.res.join end def end_accepting @@ -444,8 +444,7 @@ def test_accept_verbatim_parseable_error expected = <<-EXPECTED -
#{inner}
-
+#{inner}
EXPECTED
assert_equal expected, @to.res.join
@@ -604,8 +603,9 @@ def test_list_verbatim_2
one
-verb1 -verb2+
verb1 +verb2 +
two
hi\n world\n", @to.res.join + assert_equal "\n
hi\n world\n\n", @to.res.join assert_equal 10, @to.characters end @@ -427,8 +427,7 @@ def test_accept_verbatim_ruby_error expected = <<-EXPECTED -
#{inner}
-
+#{inner}
EXPECTED
assert_equal expected, @to.res.join
@@ -588,8 +587,9 @@ def test_convert_limit_verbatim_multiline
expected = <<-EXPECTED
Look for directives in a normal comment block: -
# :stopdoc:
-#{inner}
+# :stopdoc: +#{inner} +EXPECTED actual = @to.convert rdoc @@ -665,8 +665,9 @@ def test_list_verbatim_2 expected = <<-EXPECTED
one -
verb1 -verb2+
verb1 +verb2 +
two EXPECTED