Skip to content

Commit 1741302

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 5db4767 commit 1741302

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/rdoc/markup/to_html.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,10 @@ 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+
false
436+
end
434437
rescue SyntaxError
435438
false
436439
ensure

0 commit comments

Comments
 (0)