[ruby/rdoc] 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. https://github.com/ruby/rdoc/commit/d19f7c66fe
This commit is contained in:
parent
628cc7e12d
commit
df5330b04e
@ -430,7 +430,9 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
||||
|
||||
def parseable? text
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
eval("BEGIN {return true}\n#{text}")
|
||||
catch(:valid) do
|
||||
eval("BEGIN { throw :valid, true }\n#{text}")
|
||||
end
|
||||
rescue SyntaxError
|
||||
false
|
||||
ensure
|
||||
|
Loading…
x
Reference in New Issue
Block a user