diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb
index 474a74ccc3..cbdc3d0188 100644
--- a/lib/rdoc/markup/to_html.rb
+++ b/lib/rdoc/markup/to_html.rb
@@ -75,6 +75,7 @@ class ToHtml < Markup::Formatter
'``' => :open_dquote,
"''" => :close_dquote,
}
+ HTML_CHARACTERS_REGEXP = Regexp.union(HTML_CHARACTER_ALIASES.keys)
# Transcodes +character+ to +encoding+ with a +fallback+ character.
@@ -155,13 +156,13 @@ def initialize(pipe: false, output_decoration: true)
def init_regexp_handlings
# external links
- @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)#{URL_CHARACTERS_REGEXP_STR}+\w/,
+ @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)#{URL_CHARACTERS_REGEXP_STR}+\w/o,
:HYPERLINK)
# suppress crossref: \#method \::method \ClassName \method_with_underscores
@markup.add_regexp_handling(/\\(?:[#:A-Z]|[a-z]+_[a-z0-9])/, :SUPPRESSED_CROSSREF)
- @markup.add_regexp_handling(Regexp.union(HTML_CHARACTER_ALIASES.keys), :HTML_CHARACTERS)
+ @markup.add_regexp_handling(HTML_CHARACTERS_REGEXP, :HTML_CHARACTERS)
@markup.add_regexp_handling(/\b['"`]/, :QUOTE_AFTER_WORD)
@markup.add_regexp_handling(/\B['"`]/, :QUOTE_NOT_AFTER_WORD)