Test suite for FB2 writer.
This commit is contained in:
parent
b39597a910
commit
a9429e951c
14 changed files with 105 additions and 3 deletions
|
@ -107,6 +107,15 @@ tests = [ testGroup "markdown"
|
|||
, test "reader" ["-r", "native", "-w", "native", "-s"]
|
||||
"testsuite.native" "testsuite.native"
|
||||
]
|
||||
, testGroup "fb2"
|
||||
[ fb2WriterTest "basic" [] "fb2.basic.markdown" "fb2.basic.fb2"
|
||||
, fb2WriterTest "titles" [] "fb2.titles.markdown" "fb2.titles.fb2"
|
||||
, fb2WriterTest "images" [] "fb2.images.markdown" "fb2.images.fb2"
|
||||
, fb2WriterTest "tables" [] "tables.native" "tables.fb2"
|
||||
, fb2WriterTest "math" [] "fb2.math.markdown" "fb2.math.fb2"
|
||||
, fb2WriterTest "math-webtex" ["--webtex"] "fb2.math.markdown" "fb2.math-webtex.fb2"
|
||||
, fb2WriterTest "testsuite" [] "testsuite.native" "writer.fb2"
|
||||
]
|
||||
, testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
|
||||
[ "opendocument" , "context" , "texinfo"
|
||||
, "man" , "plain" , "mediawiki", "rtf", "org", "asciidoc"
|
||||
|
@ -142,14 +151,27 @@ writerTests format
|
|||
opts = ["-r", "native", "-w", format, "--columns=78"]
|
||||
|
||||
s5WriterTest :: String -> [String] -> String -> Test
|
||||
s5WriterTest modifier opts format
|
||||
s5WriterTest modifier opts format
|
||||
= test (format ++ " writer (" ++ modifier ++ ")")
|
||||
(["-r", "native", "-w", format] ++ opts)
|
||||
(["-r", "native", "-w", format] ++ opts)
|
||||
"s5.native" ("s5." ++ modifier <.> "html")
|
||||
|
||||
fb2WriterTest :: String -> [String] -> String -> String -> Test
|
||||
fb2WriterTest title opts inputfile normfile =
|
||||
testWithNormalize (ignoreBinary . formatXML)
|
||||
title (["-t", "fb2"]++opts) inputfile normfile
|
||||
where
|
||||
formatXML xml = splitTags $ zip xml (drop 1 xml)
|
||||
splitTags [] = []
|
||||
splitTags [end] = fst end : snd end : []
|
||||
splitTags (('>','<'):rest) = ">\n" ++ splitTags rest
|
||||
splitTags ((c,_):rest) = c : splitTags rest
|
||||
ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines
|
||||
startsWith tag str = all (uncurry (==)) $ zip tag str
|
||||
|
||||
markdownCitationTests :: [Test]
|
||||
markdownCitationTests
|
||||
= map styleToTest ["chicago-author-date","ieee","mhra"]
|
||||
= map styleToTest ["chicago-author-date","ieee","mhra"]
|
||||
++ [test "natbib" wopts "markdown-citations.txt"
|
||||
"markdown-citations.txt"]
|
||||
where
|
||||
|
|
2
tests/fb2.basic.fb2
Normal file
2
tests/fb2.basic.fb2
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?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 /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><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 link<a l:href="#l1" type="note"><sup>[1]</sup></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="#n2" type="note"><sup>[2]</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="l1"><title><p>1</p></title><p><code>http://example.com/</code></p></section><section id="n2"><title><p>2</p></title><p>Sometimes.</p></section></body></FictionBook>
|
33
tests/fb2.basic.markdown
Normal file
33
tests/fb2.basic.markdown
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Top-level title
|
||||
|
||||
## Section
|
||||
|
||||
### Subsection
|
||||
|
||||
This *emphasized* **strong** `verbatim` markdown.
|
||||
See this [link](http://example.com/).
|
||||
|
||||
Ordered list:
|
||||
|
||||
1. one
|
||||
1. two
|
||||
1. three
|
||||
|
||||
> Blockquote
|
||||
> is
|
||||
> for
|
||||
> citatons.
|
||||
|
||||
Code
|
||||
block
|
||||
is
|
||||
for
|
||||
code.
|
||||
|
||||
~~Strikeout~~ is Pandoc's extension.
|
||||
Superscript and subscripts too: H~2~O is a liquid[^1].
|
||||
2^10^ is 1024.
|
||||
|
||||
Math is another Pandoc extension: $E = m c^2$.
|
||||
|
||||
[^1]: Sometimes.
|
2
tests/fb2.images.fb2
Normal file
2
tests/fb2.images.fb2
Normal file
File diff suppressed because one or more lines are too long
13
tests/fb2.images.markdown
Normal file
13
tests/fb2.images.markdown
Normal file
|
@ -0,0 +1,13 @@
|
|||
This example test if Pandoc correctly embeds images into FictionBook.
|
||||
|
||||
Small inline image: ![alt text a small PNG image][inline-image].
|
||||
|
||||
Paragraph image:
|
||||
|
||||
![alt text of a big JPEG image](fb2.test.jpg "image title text")
|
||||
|
||||
![alt text of a big missing image](missing.jpg)
|
||||
|
||||
A missing image inline: ![alt text of missing image](missing.jpg).
|
||||
|
||||
[inline-image]: fb2.test-small.png
|
2
tests/fb2.math-webtex.fb2
Normal file
2
tests/fb2.math-webtex.fb2
Normal file
File diff suppressed because one or more lines are too long
2
tests/fb2.math.fb2
Normal file
2
tests/fb2.math.fb2
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?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 /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><p>List math:</p><p>• <code>E = m c^2</code></p><p>• <code>A = \pi r^2</code></p><p>Inline math: <code>x=\frac{-b \pm \sqrt {b^2-4ac}}{2a}</code>.</p><p>Display math:</p><code>\int_a^b \! f(x)\,dx = F(b) - F(a).</code></section></body></FictionBook>
|
10
tests/fb2.math.markdown
Normal file
10
tests/fb2.math.markdown
Normal file
|
@ -0,0 +1,10 @@
|
|||
List math:
|
||||
|
||||
- $E = m c^2$
|
||||
- $A = \pi r^2$
|
||||
|
||||
Inline math: $x=\frac{-b \pm \sqrt {b^2-4ac}}{2a}$.
|
||||
|
||||
Display math:
|
||||
|
||||
$$\int_a^b \! f(x)\,dx = F(b) - F(a).$$
|
BIN
tests/fb2.test-small.png
Normal file
BIN
tests/fb2.test-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4 KiB |
BIN
tests/fb2.test.jpg
Normal file
BIN
tests/fb2.test.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
2
tests/fb2.titles.fb2
Normal file
2
tests/fb2.titles.fb2
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?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 /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><title><p>Simple title</p></title><p>This example tests if Pandoc doesn't insert forbidden elements in FictionBook titles.</p></section><section><title><p>Emphasized Strong Title</p></title></section><section><title><p>Title with</p><empty-line /><p>line break</p></title></section></body></FictionBook>
|
10
tests/fb2.titles.markdown
Normal file
10
tests/fb2.titles.markdown
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Simple title
|
||||
|
||||
This example tests if Pandoc doesn't insert forbidden elements in FictionBook titles.
|
||||
|
||||
# *Emphasized* **Strong** Title
|
||||
|
||||
# Title with\
|
||||
line break
|
||||
|
||||
|
2
tests/tables.fb2
Normal file
2
tests/tables.fb2
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?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 /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><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>
|
2
tests/writer.fb2
Normal file
2
tests/writer.fb2
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue