diff options
author | Benoit Daloze <[email protected]> | 2023-07-26 14:08:23 +0200 |
---|---|---|
committer | git <[email protected]> | 2023-07-29 15:31:48 +0000 |
commit | df5330b04eda80d00a1f406573ae6b9e5f71c533 (patch) | |
tree | 6d7a90e5cfdba521f07f23b26ba7810f94a6a8cf | |
parent | 628cc7e12d7e5cdee2fea7d4490f6f5fbef3adb9 (diff) |
[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
-rw-r--r-- | lib/rdoc/markup/to_html.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index b33cb620ec..6c9f5733a2 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -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 |