Skip to content

Commit d19f7c6

Browse files
committed
Use a more portable way to check if code is parseable
* The same as used in irb: https://github.com/ruby/irb/pull/134/files * This works on all Ruby implementations, unlike `return` in BEGIN which can be quite difficult to support.
1 parent 0e3a24c commit d19f7c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/rdoc/markup/to_html.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ def list_end_for(list_type)
430430

431431
def parseable? text
432432
verbose, $VERBOSE = $VERBOSE, nil
433-
eval("BEGIN {return true}\n#{text}")
433+
catch(:valid) do
434+
eval("BEGIN { throw :valid, true }\n#{text}")
435+
end
434436
rescue SyntaxError
435437
false
436438
ensure

0 commit comments

Comments
 (0)