Skip to content

Commit

Permalink
roff: don't squeeze newlines inside code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Feb 21, 2016
1 parent 50b65cc commit e0d7da6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/md2man/roff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def preprocess document
end

def postprocess document
super.lstrip.squeeze("\n") # squeeze \n\n to prevent double-spaced output
super.lstrip.

# squeeze newlines between roff directives to prevent double-spaced output
# and also at the end of the document, after the very last roff directive
gsub(/(\n){2,}(?=\.|\z)/, '\1')
end

#---------------------------------------------------------------------------
Expand Down
33 changes: 33 additions & 0 deletions test/md2man/roff_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,39 @@ def heredoc document
|.RE
OUTPUT

@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
| just some *paragraph*
|
| spanning
|
|
| **multiple**
|
| > lines
| with 4-space indent
|
|
| and blank lines within
INPUT
|.PP
|.RS
|.nf
|just some *paragraph*
|
| spanning
|
|
| **multiple**
|
|> lines
|with 4\\-space indent
|
|
|and blank lines within
|.fi
|.RE
OUTPUT

@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|normal paragraph line
|
Expand Down

0 comments on commit e0d7da6

Please sign in to comment.