require 'test_helper' require 'md2man/html/engine' describe 'html engine' do before do @markdown = Md2Man::HTML::ENGINE end def heredoc document document.gsub(/^\s*\|/, '').chomp end it 'renders nothing as nothing' do @markdown.render('').must_be_empty end it 'renders paragraphs' do @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT)) |just some paragraph |spanning |multiple |lines |but within 4-space indent INPUT |
just some paragraph |spanning |multiple |lines |but within 4-space indent
OUTPUT end it 'renders tagged paragraphs with uniformly two-space indented bodies' do @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT)) |just some paragraph | spanning | multiple | lines | but within 4-space indent | | and a single line following | | and multiple | lines following INPUT |For example, the printf(3)
cross reference would be emitted as this HTML:
<a class="md2man-xref" href="../man3/printf.3.html">printf(3)</a>
|
|
OUTPUT
end
it 'renders references to other man pages as hyperlinks in middle of line' do
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|convert them from markdown(7) into roff(7), using
INPUT
|convert them from markdown(7) into roff(7), using
OUTPUT end it 'renders references to other man pages as hyperlinks at beginning of line' do @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT)) |markdown(1) into roff(2) INPUT |markdown(1) into roff(2)
OUTPUT end it 'renders references inside code blocks' do @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT)) | this is a code block | containing markdown(7), | roff(7), and much more! INPUT |this is a code block
|containing markdown(7),
|roff(7), and much more!
|
|
OUTPUT
end
it 'renders references inside code spans' do
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|this is a code span `containing markdown(7), roff(7), and` much more!
INPUT
|this is a code span containing markdown(7), roff(7), and
much more!
_______ _______
| ___ /___________ /__
| _ __/ __ \\ __/ /_/
| / /_/ /_/ / / / ,\\
| \\__/\\____/_/ /_/|_\\
| >>>------>
|
|
OUTPUT
end
it 'adds ID attributes on headings for permalinking' do
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|# foo *BAR*
|## bar BAZ
|### --BAZ-QUX--
|#### qux (MOZ)
|##### {m}oz END
INPUT