From f85b9872362bbb057ab90a321360ac295cc92084 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 5 May 2026 15:30:11 +0200 Subject: [PATCH] Use prism to check if code is valid A bit nicer than what it currently does --- lib/rdoc/markup/to_html.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index 90eff47840..7c04230f67 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'cgi/escape' require 'cgi/util' unless defined?(CGI::EscapeExt) +require 'prism' ## # Outputs RDoc markup as HTML. @@ -568,14 +569,7 @@ def list_end_for(list_type) # Returns true if text is valid ruby syntax def parseable?(text) - verbose, $VERBOSE = $VERBOSE, nil - catch(:valid) do - eval("BEGIN { throw :valid, true }\n#{text}") - end - rescue SyntaxError - false - ensure - $VERBOSE = verbose + Prism.parse_success?(text) end ##