diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-04-26 12:29:17 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-04-26 12:29:17 -0700 |
commit | 5f0d407279e453107b28ee71fa0e45c5cc93090c (patch) | |
tree | 2a9e5cd496201a7e4aff5b5e97e7a17fe7acfecb | |
parent | a96c762a10f9b6e97a5660664750ad6e3ef7f5b7 (diff) | |
parent | 619aaf29aa0bee2c8683fa5b73dcd23a8695b9e7 (diff) | |
download | pandoc-5f0d407279e453107b28ee71fa0e45c5cc93090c.tar.gz |
Merge branch 'labdsf-fb2-hrblankline'
-rw-r--r-- | src/Text/Pandoc/Writers/FB2.hs | 11 | ||||
-rw-r--r-- | test/Tests/Writers/FB2.hs | 4 | ||||
-rw-r--r-- | test/fb2/basic.fb2 | 76 | ||||
-rw-r--r-- | test/tables.fb2 | 15 | ||||
-rw-r--r-- | test/writer.fb2 | 105 |
5 files changed, 148 insertions, 63 deletions
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs index e1fa7f474..a46011a8f 100644 --- a/src/Text/Pandoc/Writers/FB2.hs +++ b/src/Text/Pandoc/Writers/FB2.hs @@ -365,10 +365,7 @@ blockToXml h@Header{} = do -- should not occur after hierarchicalize, except inside lists/blockquotes report $ BlockNotRendered h return [] -blockToXml HorizontalRule = return - [ el "empty-line" () - , el "p" (txt (replicate 10 '—')) - , el "empty-line" () ] +blockToXml HorizontalRule = return [ el "empty-line" () ] blockToXml (Table caption aligns _ headers rows) = do hd <- mkrow "th" headers aligns bd <- mapM (\r -> mkrow "td" r aligns) rows @@ -398,7 +395,7 @@ plainToPara [] = [] plainToPara (Plain inlines : rest) = Para inlines : plainToPara rest plainToPara (Para inlines : rest) = - Para inlines : Plain [LineBreak] : plainToPara rest + Para inlines : HorizontalRule : plainToPara rest -- HorizontalRule will be converted to <empty-line /> plainToPara (p:rest) = p : plainToPara rest -- Simulate increased indentation level. Will not really work @@ -449,8 +446,8 @@ toXml (Quoted DoubleQuote ss) = do toXml (Cite _ ss) = cMapM toXml ss -- FIXME: support citation styles toXml (Code _ s) = return [el "code" s] toXml Space = return [txt " "] -toXml SoftBreak = return [txt " "] -toXml LineBreak = return [el "empty-line" ()] +toXml SoftBreak = return [txt "\n"] +toXml LineBreak = return [txt "\n"] toXml (Math _ formula) = insertMath InlineImage formula toXml il@(RawInline _ _) = do report $ InlineNotRendered il diff --git a/test/Tests/Writers/FB2.hs b/test/Tests/Writers/FB2.hs index 5a04d9159..7699c58e9 100644 --- a/test/Tests/Writers/FB2.hs +++ b/test/Tests/Writers/FB2.hs @@ -25,8 +25,8 @@ tests = [ testGroup "block elements" ] , testGroup "inlines" [ - "Emphasis" =: emph "emphasized" - =?> fb2 "<emphasis>emphasized</emphasis>" + "Emphasis" =: para (emph "emphasized") + =?> fb2 "<p><emphasis>emphasized</emphasis></p>" ] , "bullet list" =: bulletList [ plain $ text "first" , plain $ text "second" diff --git a/test/fb2/basic.fb2 b/test/fb2/basic.fb2 index b5dbfc145..df71e8456 100644 --- a/test/fb2/basic.fb2 +++ b/test/fb2/basic.fb2 @@ -1,3 +1,75 @@ <?xml version="1.0" encoding="UTF-8"?> -<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info><genre>unrecognised</genre></title-info><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><section><title><p>Top-level title</p></title><section><title><p>Section</p></title><section><title><p>Subsection</p></title><p>This <emphasis>emphasized</emphasis> <strong>strong</strong> <code>verbatim</code> markdown. See this <a l:href="http://example.com/">link</a>.</p><p>Ordered list:</p><p>1. one</p><p>2. two</p><p>3. three</p><cite><p>Blockquote is for citatons.</p></cite><empty-line /><p><code>Code</code></p><p><code>block</code></p><p><code>is</code></p><p><code>for</code></p><p><code>code.</code></p><empty-line /><p><strikethrough>Strikeout</strikethrough> is Pandoc’s extension. Superscript and subscripts too: H<sub>2</sub>O is a liquid<a l:href="#n1" type="note"><sup>[1]</sup></a>. 2<sup>10</sup> is 1024.</p><p>Math is another Pandoc extension: <code>E = m c^2</code>.</p></section></section></section></body><body name="notes"><section id="n1"><title><p>1</p></title><p>Sometimes.</p></section></body></FictionBook> - +<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"> +<description> +<title-info> +<genre>unrecognised</genre> +</title-info> +<document-info> +<program-used>pandoc</program-used> +</document-info> +</description> +<body> +<title> +<p /> +</title> +<section> +<title> +<p>Top-level title</p> +</title> +<section> +<title> +<p>Section</p> +</title> +<section> +<title> +<p>Subsection</p> +</title> +<p>This <emphasis>emphasized</emphasis> <strong>strong</strong> <code>verbatim</code> markdown. +See this <a l:href="http://example.com/">link</a>.</p> +<p>Ordered list:</p> +<p>1. one</p> +<p>2. two</p> +<p>3. three</p> +<cite> +<p>Blockquote +is +for +citatons.</p> +</cite> +<empty-line /> +<p> +<code>Code</code> +</p> +<p> +<code>block</code> +</p> +<p> +<code>is</code> +</p> +<p> +<code>for</code> +</p> +<p> +<code>code.</code> +</p> +<empty-line /> +<p> +<strikethrough>Strikeout</strikethrough> is Pandoc’s extension. +Superscript and subscripts too: H<sub>2</sub>O is a liquid<a l:href="#n1" type="note"> +<sup>[1]</sup> +</a>. +2<sup>10</sup> is 1024.</p> +<p>Math is another Pandoc extension: <code>E = m c^2</code>.</p> +</section> +</section> +</section> +</body> +<body name="notes"> +<section id="n1"> +<title> +<p>1</p> +</title> +<p>Sometimes.</p> +</section> +</body> +</FictionBook> diff --git a/test/tables.fb2 b/test/tables.fb2 index 56ed5316b..6be553df9 100644 --- a/test/tables.fb2 +++ b/test/tables.fb2 @@ -1,3 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> -<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info><genre>unrecognised</genre></title-info><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><section><p>Simple table with caption:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis>Demonstration of simple table syntax.</emphasis></p><p>Simple table without caption:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis /></p><p>Simple table indented two spaces:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis>Demonstration of simple table syntax.</emphasis></p><p>Multiline table with caption:</p><table><tr><th align="center">Centered Header</th><th align="left">Left Aligned</th><th align="right">Right Aligned</th><th align="left">Default aligned</th></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note the blank line between rows.</td></tr></table><p><emphasis>Here’s the caption. It may span multiple lines.</emphasis></p><p>Multiline table without caption:</p><table><tr><th align="center">Centered Header</th><th align="left">Left Aligned</th><th align="right">Right Aligned</th><th align="left">Default aligned</th></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note the blank line between rows.</td></tr></table><p><emphasis /></p><p>Table without column headers:</p><table><tr><th align="right" /><th align="left" /><th align="center" /><th align="right" /></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="right">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="right">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="right">1</td></tr></table><p><emphasis /></p><p>Multiline table without column headers:</p><table><tr><th align="center" /><th align="left" /><th align="right" /><th align="left" /></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note the blank line between rows.</td></tr></table><p><emphasis /></p></section></body></FictionBook> +<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info><genre>unrecognised</genre></title-info><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><section><p>Simple table with caption:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis>Demonstration of simple table syntax.</emphasis></p><p>Simple table without caption:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis /></p><p>Simple table indented two spaces:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis>Demonstration of simple table syntax.</emphasis></p><p>Multiline table with caption:</p><table><tr><th align="center">Centered +Header</th><th align="left">Left +Aligned</th><th align="right">Right +Aligned</th><th align="left">Default aligned</th></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans +multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note +the blank line between rows.</td></tr></table><p><emphasis>Here’s the caption. +It may span multiple lines.</emphasis></p><p>Multiline table without caption:</p><table><tr><th align="center">Centered +Header</th><th align="left">Left +Aligned</th><th align="right">Right +Aligned</th><th align="left">Default aligned</th></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans +multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note +the blank line between rows.</td></tr></table><p><emphasis /></p><p>Table without column headers:</p><table><tr><th align="right" /><th align="left" /><th align="center" /><th align="right" /></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="right">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="right">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="right">1</td></tr></table><p><emphasis /></p><p>Multiline table without column headers:</p><table><tr><th align="center" /><th align="left" /><th align="right" /><th align="left" /></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans +multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note +the blank line between rows.</td></tr></table><p><emphasis /></p></section></body></FictionBook> diff --git a/test/writer.fb2 b/test/writer.fb2 index ceebac65c..b2d002230 100644 --- a/test/writer.fb2 +++ b/test/writer.fb2 @@ -22,9 +22,8 @@ <p>Pandoc Test Suite</p> </title> <section> -<p>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</p> -<empty-line /> -<p>——————————</p> +<p>This is a set of tests for pandoc. Most of them are adapted from +John Gruber’s markdown test suite.</p> <empty-line /> </section> <section> @@ -76,8 +75,6 @@ </title> <p>with no blank line</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> </section> <section> @@ -85,11 +82,15 @@ <p>Paragraphs</p> </title> <p>Here’s a regular paragraph.</p> -<p>In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.</p> -<p>Here’s one with a bullet. * criminey.</p> -<p>There should be a hard line break<empty-line />here.</p> -<empty-line /> -<p>——————————</p> +<p>In Markdown 1.0.0 and earlier. Version +8. This line turns into a list item. +Because a hard-wrapped line in the +middle of a paragraph looked like a +list item.</p> +<p>Here’s one with a bullet. +* criminey.</p> +<p>There should be a hard line break +here.</p> <empty-line /> </section> <section> @@ -98,7 +99,8 @@ </title> <p>E-mail style:</p> <cite> -<p>This is a block quote. It is pretty short.</p> +<p>This is a block quote. +It is pretty short.</p> </cite> <cite> <p>Code in a block quote:</p> @@ -124,11 +126,10 @@ <p>nested</p> </cite> </cite> -<p>This should not be a block quote: 2 > 1.</p> +<p>This should not be a block quote: 2 +> 1.</p> <p>And a following paragraph.</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -174,8 +175,6 @@ </p> <empty-line /> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -248,7 +247,8 @@ <p>Multiple paragraphs:</p> <p>1. Item 1, graf one.</p> <empty-line /> -<p> Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</p> +<p> Item 1. graf two. The quick brown fox jumped over the lazy dog’s +back.</p> <empty-line /> <p>2. Item 2.</p> <empty-line /> @@ -284,13 +284,17 @@ <title> <p>Tabs and spaces</p> </title> -<p>• this is a list item indented with tabs</p> +<p>• this is a list item +indented with tabs</p> <empty-line /> -<p>• this is a list item indented with spaces</p> +<p>• this is a list item +indented with spaces</p> <empty-line /> -<p>• • this is an example list item indented with tabs</p> +<p>• • this is an example list item +indented with tabs</p> <empty-line /> -<p>• • this is an example list item indented with spaces</p> +<p>• • this is an example list item +indented with spaces</p> <empty-line /> </section> <section> @@ -302,7 +306,8 @@ <empty-line /> <p> with a continuation</p> <empty-line /> -<p>(3) iv. sublist with roman numerals, starting with 4</p> +<p>(3) iv. sublist with roman numerals, +starting with 4</p> <p>(3) v. more items</p> <p>(3) v. (A) a subsublist</p> <p>(3) v. (B) a subsublist</p> @@ -319,8 +324,6 @@ <p>M.A. 2007</p> <p>B. Williams</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> </section> <section> @@ -377,7 +380,8 @@ </p> <p> red fruit</p> <empty-line /> -<p> contains seeds, crisp, pleasant to taste</p> +<p> contains seeds, +crisp, pleasant to taste</p> <empty-line /> <p> <strong> @@ -479,8 +483,6 @@ <empty-line /> <p>Hr’s:</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -515,9 +517,8 @@ <emphasis>hello</emphasis> </sup> a<sup>hello there</sup>.</p> <p>Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.</p> -<p>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</p> -<empty-line /> -<p>——————————</p> +<p>These should not be superscripts or subscripts, +because of the unescaped spaces: a^b c^d, a~b c~d.</p> <empty-line /> </section> <section> @@ -526,15 +527,15 @@ </title> <p>“Hello,” said the spider. “‘Shelob’ is my name.”</p> <p>‘A’, ‘B’, and ‘C’ are letters.</p> -<p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’</p> -<p>‘He said, “I want to go.”’ Were you alive in the 70’s?</p> +<p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. +So is ‘pine.’</p> +<p>‘He said, “I want to go.”’ Were you alive in the +70’s?</p> <p>Here is some quoted ‘<code>code</code>’ and a “<a l:href="http://example.com/?foo=1&bar=2">quoted link</a>”.</p> <p>Some dashes: one—two — three—four — five.</p> <p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p> <p>Ellipses…and…and….</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -550,18 +551,18 @@ <p>• <code>223</code> </p> <p>• <code>p</code>-Tree</p> -<p>• Here’s some display math: <code>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</code> +<p>• Here’s some display math: +<code>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</code> </p> <p>• Here’s one that has a line break in it: <code>\alpha + \omega \times x^2</code>.</p> <p>These shouldn’t be math:</p> <p>• To get the famous equation, write <code>$e = mc^2$</code>.</p> -<p>• $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It worked if “lot” is emphasized.)</p> +<p>• $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. +(It worked if “lot” is emphasized.)</p> <p>• Shoes ($20) and socks ($5).</p> <p>• Escaped <code>$</code>: $73 <emphasis>this should be emphasized</emphasis> 23$.</p> <p>Here’s a LaTeX table:</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -595,8 +596,6 @@ <p>Plus: +</p> <p>Minus: -</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -681,8 +680,6 @@ </p> <empty-line /> <empty-line /> -<p>——————————</p> -<empty-line /> </section> </section> <section> @@ -693,8 +690,6 @@ <image l:href="#image1" l:type="imageType" alt="lalune" title="Voyage dans la Lune" /> <p>Here is a movie <image l:href="#image2" l:type="inlineImageType" alt="movie" /> icon.</p> <empty-line /> -<p>——————————</p> -<empty-line /> </section> <section> <title> @@ -704,7 +699,9 @@ <sup>[1]</sup> </a> and another.<a l:href="#n2" type="note"> <sup>[2]</sup> -</a> This should <emphasis>not</emphasis> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a l:href="#n3" type="note"> +</a> +This should <emphasis>not</emphasis> be a footnote reference, because it +contains a space.[^my note] Here is an inline note.<a l:href="#n3" type="note"> <sup>[3]</sup> </a> </p> @@ -726,26 +723,33 @@ <title> <p>1</p> </title> -<p>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</p> +<p>Here is the footnote. It can go anywhere after the footnote +reference. It need not be placed at the end of the document.</p> </section> <section id="n2"> <title> <p>2</p> </title> -<p>Here’s the long note. This one contains multiple blocks.</p> -<p>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</p> +<p>Here’s the long note. This one contains multiple +blocks.</p> +<p>Subsequent blocks are indented to show that they belong to the +footnote (as with list items).</p> <empty-line /> <p> <code> { <code> }</code> </p> <empty-line /> -<p>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</p> +<p>If you want, you can indent every line, but you can also be +lazy and just indent the first line of each block.</p> </section> <section id="n3"> <title> <p>3</p> </title> -<p>This is <emphasis>easier</emphasis> to type. Inline notes may contain <a l:href="http://google.com">links</a> and <code>]</code> verbatim characters, as well as [bracketed text].</p> +<p>This +is <emphasis>easier</emphasis> to type. Inline notes may contain +<a l:href="http://google.com">links</a> and <code>]</code> verbatim characters, +as well as [bracketed text].</p> </section> <section id="n4"> <title> @@ -761,4 +765,3 @@ </section> </body> </FictionBook> - |