Skip to content

Commit

Permalink
Convert single quotes in character entity references
Browse files Browse the repository at this point in the history
As well as double quotes.

ruby#824 (comment)
  • Loading branch information
nobu committed Aug 28, 2021
1 parent 89a59f2 commit fc0dc85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rdoc/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ 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(/&#39;|'/) then # single quote
pp text
if insquotes
html << encoded[:close_squote]
insquotes = false
Expand Down
7 changes: 7 additions & 0 deletions test/rdoc/test_rdoc_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("&#39;a")
assert_equal 'a’', to_html("a&#39;")

assert_equal '‘a’ ‘', to_html("&#39;a&#39; &#39;")
end

def test_to_html_backslash
assert_equal 'S', to_html('\\S')
end
Expand Down

0 comments on commit fc0dc85

Please sign in to comment.