From 09002bdab55da42aabdc3a7e0c079e29b7d23e8a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 28 Aug 2021 12:19:26 +0900 Subject: [PATCH 1/3] Convert single quotes in character entity references As well as double quotes. https://github.com/ruby/rdoc/pull/824#discussion_r683173389 --- lib/rdoc/text.rb | 2 +- test/rdoc/test_rdoc_text.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index c3218fdb2f..2fc47daa66 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -240,7 +240,7 @@ def to_html text when s.scan(/''/) then # tick double quote html << encoded[:close_dquote] after_word = nil - when s.scan(/'/) then # single quote + when s.scan(/'|'/) then # single quote if insquotes html << encoded[:close_squote] insquotes = false diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 59d63b29bd..02c56a2829 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -485,6 +485,13 @@ def test_to_html_apostrophe assert_equal '‘a’ ‘', to_html("'a' '") end + def test_to_html_apostrophe_entity + assert_equal '‘a', to_html("'a") + assert_equal 'a’', to_html("a'") + + assert_equal '‘a’ ‘', to_html("'a' '") + end + def test_to_html_backslash assert_equal 'S', to_html('\\S') end From 82eaefbae4c5122095aade2a83824205df0da2b0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 28 Aug 2021 12:57:36 +0900 Subject: [PATCH 2/3] Convert a backtick to an open single quote --- lib/rdoc/text.rb | 8 ++++++++ test/rdoc/test_rdoc_markup_to_html.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 2fc47daa66..77318e46e4 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -240,6 +240,14 @@ def to_html text when s.scan(/''/) then # tick double quote html << encoded[:close_dquote] after_word = nil + when s.scan(/`/) then # backtick + if insquotes or after_word + html << '`' + after_word = false + else + html << encoded[:open_squote] + insquotes = true + end when s.scan(/'|'/) then # single quote if insquotes html << encoded[:close_squote] diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index 342cf71082..b2b21de806 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -712,7 +712,7 @@ def test_convert_with_exclude_tag def test_convert_underscore_adjacent_to_code assert_equal "\n

aaa_

\n", @to.convert(%q{+aaa+_}) - assert_equal "\n

`i386-mswin32_MSRTVERSION'

\n", @to.convert(%q{`+i386-mswin32_+_MSRTVERSION_'}) + assert_equal "\n

\u{2018}i386-mswin32_MSRTVERSION\u{2019}

\n", @to.convert(%q{`+i386-mswin32_+_MSRTVERSION_'}) end def test_gen_url From 6ed889aac9fed547f743c9057681c1065d56110a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 10 Sep 2021 22:56:13 +0900 Subject: [PATCH 3/3] Convert tick double quote in character entity references --- lib/rdoc/text.rb | 2 +- test/rdoc/test_rdoc_text.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 77318e46e4..407421f453 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -237,7 +237,7 @@ def to_html text when s.scan(/``/) then # backtick double quote html << encoded[:open_dquote] after_word = nil - when s.scan(/''/) then # tick double quote + when s.scan(/(?:'|'){2}/) then # tick double quote html << encoded[:close_dquote] after_word = nil when s.scan(/`/) then # backtick diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 02c56a2829..590d41c3d9 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -514,6 +514,7 @@ def test_to_html_dash def test_to_html_double_backtick assert_equal '“a', to_html('``a') assert_equal '“a“', to_html('``a``') + assert_equal '“a”', to_html("``a''") end def test_to_html_double_quote