Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly escape single quote. #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ronn/roff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ def escape(text)
text.gsub!(/&#(\d+);/) { $1.to_i.chr } # dec entities
text.gsub!('\\', '\e') # backslash
text.gsub!('...', '\|.\|.\|.') # ellipses
text.gsub!(/['.-]/) { |m| "\\#{m}" } # control chars
text.gsub!(/'/, '\(cq') # single quoute
text.gsub!(/[.-]/) { |m| "\\#{m}" } # control chars
text.gsub!(/(&[A-Za-z]+;)/) { ent[$1] || $1 } # named entities
text.gsub!('&', '&') # amps
text
Expand Down
4 changes: 2 additions & 2 deletions test/dots_at_line_start_test.roff
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\fBdots_at_line_start_test\fR
.
.P
There\'s a weird issue where dots at the beginning of a line generate troff warnings due to escaping\.
There\(cqs a weird issue where dots at the beginning of a line generate troff warnings due to escaping\.
.
.P
\&\.\. let\'s see what happens\.
\&\.\. let\(cqs see what happens\.
2 changes: 1 addition & 1 deletion test/ellipses.roff
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Ellipses should be replaced\|\.\|\.\|\.
.
.P
\|\.\|\.\|\.also, they shouldn\'t interfere with regular dots at the beginning of a line\.
\|\.\|\.\|\.also, they shouldn\(cqt interfere with regular dots at the beginning of a line\.
4 changes: 2 additions & 2 deletions test/entity_encoding_test.roff
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Your output <i>might</i> look like this:
.IP "" 0
.
.P
Here\'s some special entities:
Here\(cqs some special entities:
.
.IP "\[ci]" 4
&bull; \[ci]
Expand Down Expand Up @@ -58,4 +58,4 @@ Here\'s some special entities:
.IP "" 0
.
.P
Here\'s a line that uses non\-breaking spaces to force the last\~few\~words\~to\~wrap\~together\.
Here\(cqs a line that uses non\-breaking spaces to force the last\~few\~words\~to\~wrap\~together\.
Loading