diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-12-21 22:53:22 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-12-22 09:45:02 -0800 |
commit | c4f6e6cb57e4fdda9ad59ff7220988810583ec60 (patch) | |
tree | 0f0ff888d3507326015f192e00f33b3d84760605 /test | |
parent | 7a9832166e36f77402d5e0259647e9f5c7ba4e58 (diff) | |
download | pandoc-c4f6e6cb57e4fdda9ad59ff7220988810583ec60.tar.gz |
HTML writer: make line breaks more consistent.
- With `--wrap=none`, we now output line breaks between
block-level elements. Previously they were omitted
entirely, so the whole document was on one line, unless
there were literal line breaks in pre sections. This makes
the HTML writer's behavior more consistent with that of
other writers.
- Put newline after `<dd>`.
- Put newlines after block-level elements in footnote section.
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Writers/HTML.hs | 73 | ||||
-rw-r--r-- | test/command/853.md | 5 | ||||
-rw-r--r-- | test/writer.html4 | 66 | ||||
-rw-r--r-- | test/writer.html5 | 66 |
4 files changed, 149 insertions, 61 deletions
diff --git a/test/Tests/Writers/HTML.hs b/test/Tests/Writers/HTML.hs index 50775b171..a81badae8 100644 --- a/test/Tests/Writers/HTML.hs +++ b/test/Tests/Writers/HTML.hs @@ -2,6 +2,7 @@ module Tests.Writers.HTML (tests) where import Data.Text (unpack) +import qualified Data.Text as T import Test.Tasty import Tests.Helpers import Text.Pandoc @@ -68,7 +69,7 @@ tests = , testGroup "blocks" [ "definition list with empty <dt>" =: definitionList [(mempty, [para $ text "foo bar"])] - =?> "<dl><dt></dt><dd><p>foo bar</p></dd></dl>" + =?> "<dl>\n<dt></dt>\n<dd>\n<p>foo bar</p>\n</dd>\n</dl>" , "heading with disallowed attributes" =: headerWith ("", [], [("invalid","1"), ("lang", "en")]) 1 "test" =?> @@ -108,37 +109,66 @@ tests = [ test (htmlWithOpts def{writerReferenceLocation=EndOfDocument}) "at the end of a document" $ noteTestDoc =?> - concat + T.unlines [ "<h1>Page title</h1>" , "<h2>First section</h2>" , "<p>This is a footnote.<a href=\"#fn1\" class=\"footnote-ref\" id=\"fnref1\"><sup>1</sup></a> And this is a <a href=\"https://www.google.com\">link</a>.</p>" - , "<blockquote><p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p><p>A second paragraph.</p></blockquote>" + , "<blockquote>" + , "<p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p>" + , "<p>A second paragraph.</p>" + , "</blockquote>" , "<h2>Second section</h2>" , "<p>Some more text.</p>" - , "<div class=\"footnotes footnotes-end-of-document\"><hr /><ol><li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li><li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li></ol></div>" + , "<div class=\"footnotes footnotes-end-of-document\">" + , "<hr />" + , "<ol>" + , "<li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li>" + , "<li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li>" + , "</ol>" + , "</div>" ] , test (htmlWithOpts def{writerReferenceLocation=EndOfBlock}) "at the end of a block" $ noteTestDoc =?> - concat + T.unlines [ "<h1>Page title</h1>" , "<h2>First section</h2>" , "<p>This is a footnote.<a href=\"#fn1\" class=\"footnote-ref\" id=\"fnref1\"><sup>1</sup></a> And this is a <a href=\"https://www.google.com\">link</a>.</p>" - , "<div class=\"footnotes footnotes-end-of-block\"><ol><li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li></ol></div>" - , "<blockquote><p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p><p>A second paragraph.</p></blockquote>" - , "<div class=\"footnotes footnotes-end-of-block\"><ol start=\"2\"><li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li></ol></div>" + , "<div class=\"footnotes footnotes-end-of-block\">" + , "<ol>" + , "<li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li>" + , "</ol>" + , "</div>" + , "<blockquote>" + , "<p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p>" + , "<p>A second paragraph.</p>" + , "</blockquote>" + , "<div class=\"footnotes footnotes-end-of-block\">" + , "<ol start=\"2\">" + , "<li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li>" + , "</ol>" + , "</div>" , "<h2>Second section</h2>" , "<p>Some more text.</p>" ] , test (htmlWithOpts def{writerReferenceLocation=EndOfSection}) "at the end of a section" $ noteTestDoc =?> - concat + T.unlines [ "<h1>Page title</h1>" , "<h2>First section</h2>" , "<p>This is a footnote.<a href=\"#fn1\" class=\"footnote-ref\" id=\"fnref1\"><sup>1</sup></a> And this is a <a href=\"https://www.google.com\">link</a>.</p>" - , "<blockquote><p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p><p>A second paragraph.</p></blockquote>" - , "<div class=\"footnotes footnotes-end-of-section\"><hr /><ol><li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li><li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li></ol></div>" + , "<blockquote>" + , "<p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p>" + , "<p>A second paragraph.</p>" + , "</blockquote>" + , "<div class=\"footnotes footnotes-end-of-section\">" + , "<hr />" + , "<ol>" + , "<li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li>" + , "<li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li>" + , "</ol>" + , "</div>" , "<h2>Second section</h2>" , "<p>Some more text.</p>" ] @@ -147,15 +177,28 @@ tests = noteTestDoc =?> -- Footnotes are rendered _after_ their section (in this case after the level2 section -- that contains it). - concat + T.unlines [ "<div class=\"section level1\">" , "<h1>Page title</h1>" , "<div class=\"section level2\">" , "<h2>First section</h2>" - , "<p>This is a footnote.<a href=\"#fn1\" class=\"footnote-ref\" id=\"fnref1\"><sup>1</sup></a> And this is a <a href=\"https://www.google.com\">link</a>.</p><blockquote><p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p><p>A second paragraph.</p></blockquote>" + , "<p>This is a footnote.<a href=\"#fn1\" class=\"footnote-ref\" id=\"fnref1\"><sup>1</sup></a> And this is a <a href=\"https://www.google.com\">link</a>.</p>" + , "<blockquote>" + , "<p>A note inside a block quote.<a href=\"#fn2\" class=\"footnote-ref\" id=\"fnref2\"><sup>2</sup></a></p>" + , "<p>A second paragraph.</p>" + , "</blockquote>" + , "</div>" + , "<div class=\"footnotes footnotes-end-of-section\">" + , "<hr />" + , "<ol>" + , "<li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li>" + , "<li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li>" + , "</ol>" + , "</div>" + , "<div class=\"section level2\">" + , "<h2>Second section</h2>" + , "<p>Some more text.</p>" , "</div>" - , "<div class=\"footnotes footnotes-end-of-section\"><hr /><ol><li id=\"fn1\"><p>Down here.<a href=\"#fnref1\" class=\"footnote-back\">↩︎</a></p></li><li id=\"fn2\"><p>The second note.<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li></ol></div>" - , "<div class=\"section level2\"><h2>Second section</h2><p>Some more text.</p></div>" , "</div>" ] ] diff --git a/test/command/853.md b/test/command/853.md index bcc3b4654..518c6593b 100644 --- a/test/command/853.md +++ b/test/command/853.md @@ -12,8 +12,9 @@ class="citation">[CIT2002]</a>.</p> <div id="citations"> <dl> <dt><span id="CIT2002" class="citation-label">CIT2002</span></dt> -<dd><p>This is the citation. It's just like a footnote, except the label -is textual.</p> +<dd> +<p>This is the citation. It's just like a footnote, except the label is +textual.</p> </dd> </dl> </div> diff --git a/test/writer.html4 b/test/writer.html4 index e2adcf5bc..1e255fa70 100644 --- a/test/writer.html4 +++ b/test/writer.html4 @@ -376,47 +376,58 @@ back.</p></li> <p>Tight using spaces:</p> <dl> <dt>apple</dt> -<dd>red fruit +<dd> +red fruit </dd> <dt>orange</dt> -<dd>orange fruit +<dd> +orange fruit </dd> <dt>banana</dt> -<dd>yellow fruit +<dd> +yellow fruit </dd> </dl> <p>Tight using tabs:</p> <dl> <dt>apple</dt> -<dd>red fruit +<dd> +red fruit </dd> <dt>orange</dt> -<dd>orange fruit +<dd> +orange fruit </dd> <dt>banana</dt> -<dd>yellow fruit +<dd> +yellow fruit </dd> </dl> <p>Loose:</p> <dl> <dt>apple</dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> </dd> <dt>orange</dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> </dd> <dt>banana</dt> -<dd><p>yellow fruit</p> +<dd> +<p>yellow fruit</p> </dd> </dl> <p>Multiple blocks with italics:</p> <dl> <dt><em>apple</em></dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> <p>contains seeds, crisp, pleasant to taste</p> </dd> <dt><em>orange</em></dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> <pre><code>{ orange code block }</code></pre> <blockquote> <p>orange block quote</p> @@ -426,38 +437,49 @@ back.</p></li> <p>Multiple definitions, tight:</p> <dl> <dt>apple</dt> -<dd>red fruit +<dd> +red fruit </dd> -<dd>computer +<dd> +computer </dd> <dt>orange</dt> -<dd>orange fruit +<dd> +orange fruit </dd> -<dd>bank +<dd> +bank </dd> </dl> <p>Multiple definitions, loose:</p> <dl> <dt>apple</dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> </dd> -<dd><p>computer</p> +<dd> +<p>computer</p> </dd> <dt>orange</dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> </dd> -<dd><p>bank</p> +<dd> +<p>bank</p> </dd> </dl> <p>Blank line after term, indented marker, alternate markers:</p> <dl> <dt>apple</dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> </dd> -<dd><p>computer</p> +<dd> +<p>computer</p> </dd> <dt>orange</dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> <ol style="list-style-type: decimal"> <li>sublist</li> <li>sublist</li> diff --git a/test/writer.html5 b/test/writer.html5 index cdfcf042f..d8e89b3e2 100644 --- a/test/writer.html5 +++ b/test/writer.html5 @@ -379,47 +379,58 @@ back.</p></li> <p>Tight using spaces:</p> <dl> <dt>apple</dt> -<dd>red fruit +<dd> +red fruit </dd> <dt>orange</dt> -<dd>orange fruit +<dd> +orange fruit </dd> <dt>banana</dt> -<dd>yellow fruit +<dd> +yellow fruit </dd> </dl> <p>Tight using tabs:</p> <dl> <dt>apple</dt> -<dd>red fruit +<dd> +red fruit </dd> <dt>orange</dt> -<dd>orange fruit +<dd> +orange fruit </dd> <dt>banana</dt> -<dd>yellow fruit +<dd> +yellow fruit </dd> </dl> <p>Loose:</p> <dl> <dt>apple</dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> </dd> <dt>orange</dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> </dd> <dt>banana</dt> -<dd><p>yellow fruit</p> +<dd> +<p>yellow fruit</p> </dd> </dl> <p>Multiple blocks with italics:</p> <dl> <dt><em>apple</em></dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> <p>contains seeds, crisp, pleasant to taste</p> </dd> <dt><em>orange</em></dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> <pre><code>{ orange code block }</code></pre> <blockquote> <p>orange block quote</p> @@ -429,38 +440,49 @@ back.</p></li> <p>Multiple definitions, tight:</p> <dl> <dt>apple</dt> -<dd>red fruit +<dd> +red fruit </dd> -<dd>computer +<dd> +computer </dd> <dt>orange</dt> -<dd>orange fruit +<dd> +orange fruit </dd> -<dd>bank +<dd> +bank </dd> </dl> <p>Multiple definitions, loose:</p> <dl> <dt>apple</dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> </dd> -<dd><p>computer</p> +<dd> +<p>computer</p> </dd> <dt>orange</dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> </dd> -<dd><p>bank</p> +<dd> +<p>bank</p> </dd> </dl> <p>Blank line after term, indented marker, alternate markers:</p> <dl> <dt>apple</dt> -<dd><p>red fruit</p> +<dd> +<p>red fruit</p> </dd> -<dd><p>computer</p> +<dd> +<p>computer</p> </dd> <dt>orange</dt> -<dd><p>orange fruit</p> +<dd> +<p>orange fruit</p> <ol type="1"> <li>sublist</li> <li>sublist</li> |