Skip to content
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
9 changes: 2 additions & 7 deletions lib/ronn/roff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def escape(text)
text.gsub!(/&#x([0-9A-Fa-f]+);/) { $1.to_i(16).chr } # hex entities
text.gsub!(/&#(\d+);/) { $1.to_i.chr } # dec entities
text.gsub!('\\', '\e') # backslash
text.gsub!('...', '\|.\|.\|.') # ellipses
text.gsub!(/['.-]/) { |m| "\\#{m}" } # control chars
text.gsub!('...', '…') # ellipses
text.gsub!(/^['.-]/) { |m| "\\&#{m}" } # control chars
text.gsub!(/(&[A-Za-z]+;)/) { ent[$1] || $1 } # named entities
text.gsub!('&', '&') # amps
text
Expand All @@ -269,11 +269,6 @@ def quote(text)
# write text to output buffer
def write(text)
return if text.nil? || text.empty?
# lines cannot start with a '.'. insert zero-width character before.
if text[0,2] == '\.' &&
(@buf.last && @buf.last[-1] == ?\n)
@buf << '\&'
end
@buf << text
end

Expand Down
6 changes: 3 additions & 3 deletions test/definition_list_syntax.roff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.TH "DEFITION_LIST_SYNTAX" "5" "January 1979" "" ""
.
.SH "NAME"
\fBdefition_list_syntax\fR \- hiya
\fBdefition_list_syntax\fR - hiya
.
.P
Definition lists look like unordered lists:
Expand All @@ -21,6 +21,6 @@ start
new paragraphs
.
.TP
\fB\-\-somearg\fR=\fIVALUE\fR
We can do that too\.
\fB\&--somearg\fR=\fIVALUE\fR
We can do that too.

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's a weird issue where dots at the beginning of a line generate troff warnings due to escaping.
.
.P
\&\.\. let\'s see what happens\.
\&.. let's see what happens.
6 changes: 3 additions & 3 deletions test/ellipses.roff
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.TH "ELLIPSES" "7" "January 1979" "" ""
.
.SH "NAME"
\fBellipses\fR \- testing ellipses
\fBellipses\fR - testing ellipses
.
.P
Ellipses should be replaced\|\.\|\.\|\.
Ellipses should be replaced
.
.P
\|\.\|\.\|\.also, they shouldn\'t interfere with regular dots at the beginning of a line\.
also, they shouldn't interfere with regular dots at the beginning of a line.
6 changes: 3 additions & 3 deletions test/entity_encoding_test.roff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.TH "HELLO" "1" "January 1979" "" ""
.
.SH "NAME"
\fBhello\fR \- hello world
\fBhello\fR - hello world
.
.P
Your output <i>might</i> look like this:
Expand All @@ -20,7 +20,7 @@ Your output <i>might</i> look like this:
.IP "" 0
.
.P
Here\'s some special entities:
Here's 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's a line that uses non-breaking spaces to force the last\~few\~words\~to\~wrap\~together.
412 changes: 206 additions & 206 deletions test/markdown_syntax.roff

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions test/middle_paragraph.roff
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.TH "TEST" "1" "January 1979" "" ""
.
.SH "NAME"
\fBtest\fR \- just a ron test
\fBtest\fR - just a ron test
.
.SH "TEST"
Foo
.
.P
Always use \fBattr_reader\fR, \fBattr_writer\fR or \fBattr_accessor\fR\. Do not use \fBfor\|\.\|\.\|\.in\fR; use each instead\. Do not use \fBand\fR/\fBor\fR; use \fB&&\fR/\fB||\fR instead\.
Always use \fBattr_reader\fR, \fBattr_writer\fR or \fBattr_accessor\fR\&. Do not use \fBforin\fR; use each instead. Do not use \fBand\fR/\fBor\fR; use \fB&&\fR/\fB||\fR instead.
.
.P
Bar
4 changes: 2 additions & 2 deletions test/missing_spaces.roff
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
\fBmissing_spaces\fR
.
.TP
\fB\-S\fR \fItext\fR, \fBsearch\fR \fItext\fR
Performs a substring search of formula names for \fItext\fR\.
\fB\&-S\fR \fItext\fR, \fBsearch\fR \fItext\fR
Performs a substring search of formula names for \fItext\fR\&.

4 changes: 2 additions & 2 deletions test/nested_list_with_code.roff
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
\fBtoggle_status\fR
.
.IP "\[ci]" 4
Toggle the display of the status bar\.
Toggle the display of the status bar.
.
.IP "" 0

.
.IP "\[ci]" 4
\fBspawn <executable> <additional args>\fR TODO explain path\-alike expansion
\fBspawn <executable> <additional args>\fR TODO explain path-alike expansion
.
.IP "" 0

2 changes: 1 addition & 1 deletion test/pre_block_with_quotes.roff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.TH "T" "1" "January 1979" "" ""
.
.SH "NAME"
\fBt\fR \- test
\fBt\fR - test
.
.SH "test"
.
Expand Down
4 changes: 2 additions & 2 deletions test/section_reference_links.roff
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.TH "SECTION_REFERENCE_LINKS" "1" "January 1979" "" ""
.
.SH "NAME"
\fBsection_reference_links\fR \- linking to sections
\fBsection_reference_links\fR - linking to sections
.
.SH "SECTION 1"
See the following section\.
See the following section.
.
.SH "SECTION 2"
See \fISECTION 1\fR or \fIto put it another way\fR or even \fIlink this\fR
2 changes: 1 addition & 1 deletion test/test_ronn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RonnTest < Test::Unit::TestCase
assert_equal %[.TH "HELLO" "1" "November 2009" "" ""], lines.shift
assert_equal %[.], lines.shift
assert_equal %[.SH "NAME"], lines.shift
assert_equal %[\\fBhello\\fR \\- hello world], lines.shift
assert_equal %[\\fBhello\\fR - hello world], lines.shift
assert_equal 0, lines.size
end

Expand Down
12 changes: 6 additions & 6 deletions test/underline_spacing_test.roff
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
This input
.
.TP
\fB\-S\fR \fItext\fR, \fBsearch\fR \fItext\fR
Performs a substring search of formula names for \fItext\fR\.
\fB\&-S\fR \fItext\fR, \fBsearch\fR \fItext\fR
Performs a substring search of formula names for \fItext\fR\&.
.
.TP
\fB\-O\fR \fItext\fR, \fBother\fR \fItext\fR
Does something else\.
\fB\&-O\fR \fItext\fR, \fBother\fR \fItext\fR
Does something else.
.
.P
Should space text properly\.
Should space text properly.
.
.P
\fI!\-\- this is a comment \-\-\fR
\fI!-- this is a comment --\fR