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
10 changes: 4 additions & 6 deletions lib/ronn/roff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def initialize(html, name, section, tagline, manual=nil, version=nil, date=nil)
end

def to_s
@buf.join.gsub(/[ \t]+$/, '')
str = @buf.join
str.gsub!(/[ \t]+$/, '') # trailing whitespace
str.gsub!(/^(\s*)\\\./) { "#{$1}\\[char46]" } # special treatment for lines starting with period
str
end

protected
Expand Down Expand Up @@ -269,11 +272,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
17 changes: 16 additions & 1 deletion test/dots_at_line_start_test.roff
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@
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\.
\[char46]\. let\'s see what happens\.
.
.P
This is also an issue with code blocks
.
.IP "" 4
.
.nf

\[char46]/example_one
\[char46]/example_two
.
.fi
.
.IP "" 0

5 changes: 5 additions & 0 deletions test/dots_at_line_start_test.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ There's a weird issue where dots at the beginning of a line
generate troff warnings due to escaping.

.. let's see what happens.

This is also an issue with code blocks

./example_one
./example_two
2 changes: 1 addition & 1 deletion test/markdown_syntax.roff
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ _ underscore
# hash mark
+ plus sign
\- minus sign (hyphen)
\. dot
\[char46] dot
! exclamation mark
.
.fi
Expand Down