git.iko.soy/typeable/pandoc
on master help sign in
Added haddock writer tests.
commitcf15b929f833ea31b35bafb40f782e113546caa0 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 18 Jun 2014, 17:55 (12 years ago) parentff6a2ba
5 files changed+738−3
pandoc.cabal+2 tests/Tests/Old.hs+2−1 tests/haddock-reader.native+2−2 tests/tables.haddock+72 tests/writer.haddock+660
pandoc.cabal+2
@@ -135,6 +135,7 @@ Extra-Source-Files:
135135 tests/tables.opendocument,
136136 tests/tables.org,
137137 tests/tables.asciidoc,
138+ tests/tables.haddock,
138139 tests/tables.texinfo,
139140 tests/tables.rst,
140141 tests/tables.rtf,
@@ -156,6 +157,7 @@ Extra-Source-Files:
156157 tests/writer.opendocument,
157158 tests/writer.org,
158159 tests/writer.asciidoc,
160+ tests/writer.haddock,
159161 tests/writer.rst,
160162 tests/writer.rtf,
161163 tests/writer.texinfo,
tests/Tests/Old.hs+2−1
@@ -131,7 +131,8 @@ tests = [ testGroup "markdown"
131131 "opml-reader.opml" "opml-reader.native"
132132 ]
133133 , testGroup "haddock"
134− [ test "reader" ["-r", "haddock", "-w", "native", "-s"]
134+ [ testGroup "writer" $ writerTests "haddock"
135+ , test "reader" ["-r", "haddock", "-w", "native", "-s"]
135136 "haddock-reader.haddock" "haddock-reader.native"
136137 ]
137138 , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
tests/haddock-reader.native+2−2
@@ -4,14 +4,14 @@ Pandoc (Meta {unMeta = fromList []})
44,Para [Str "*",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "paragraph,",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str ">",Space,Str "This",Space,Str "sentence",Space,Str "is",Space,Str "not",Space,Str "code.",Space,Str ">>>",Space,Str "This",Space,Str "is",Space,Str "not",Space,Str "an",Space,Str "example."]
55,Para [Str "The",Space,Str "references",Space,Str "\955,",Space,Str "\955",Space,Str "and",Space,Str "\955",Space,Str "all",Space,Str "represent",Space,Str "the",Space,Str "lower-case",Space,Str "letter",Space,Str "lambda."]
66,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "code",Space,Str "block:"]
7−,CodeBlock ("",["haskell"],[]) "map :: (a -> b) -> [a] -> [b]\nmap _ [] = []\nmap f (x:xs) = f x : map f xs"
7+,CodeBlock ("",[],[]) "map :: (a -> b) -> [a] -> [b]\nmap _ [] = []\nmap f (x:xs) = f x : map f xs"
88,Para [Str "This",Space,Str "is",Space,Str "another",Space,Str "code",Space,Str "block:"]
99,Para [Code ("",[],[]) "f x = x + x.",LineBreak,Code ("",[],[]) "The @...@ code block ",Emph [Code ("",[],[]) "interprets markup normally"],Code ("",[],[]) ".",Code ("",["haskell"],[]) "Module.Foo",Code ("",[],[]) "",LineBreak,Code ("",[],[]) "\"Hello World\""]
1010,Para [Str "Haddock",Space,Str "supports",Space,Str "REPL",Space,Str "examples:"]
1111,Para [Code ("",["haskell","expr"],[]) "fib 10",LineBreak,Code ("",["result"],[]) "55"]
1212,Para [Code ("",["haskell","expr"],[]) "putStrLn \"foo\\nbar\"",LineBreak,Code ("",["result"],[]) "foo",LineBreak,Code ("",["result"],[]) "bar"]
1313,Para [Str "That",Space,Str "was",Space,Emph [Str "really",Space,Str "cool"],Str "!",Space,Str "I",Space,Str "had",Space,Str "no",Space,Str "idea",Space,Code ("",[],[]) "fib 10 = 55",Str "."]
14−,Para [Str "This",Space,Str "module",Space,Str "defines",Space,Str "the",Space,Str "type",Space,Code ("",["haskell"],[]) "T",Str ".",Space,Str "The",Space,Str "identifier",Space,Code ("",["haskell"],[]) "M.T",Space,Str "is",Space,Str "not",Space,Str "in",Space,Str "scope",Space,Str "I",Space,Str "don't",Space,Str "have",Space,Str "to",Space,Str "escape",Space,Str "my",Space,Str "apostrophes;",Space,Str "great,",Space,Str "isn't",Space,Str "it?",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "the",Space,Code ("",["haskell"],[]) "Foo",Space,Str "module."]
14+,Para [Str "This",Space,Str "module",Space,Str "defines",Space,Str "the",Space,Str "type",Space,Code ("",[],[]) "T",Str ".",Space,Str "The",Space,Str "identifier",Space,Code ("",[],[]) "M.T",Space,Str "is",Space,Str "not",Space,Str "in",Space,Str "scope",Space,Str "I",Space,Str "don't",Space,Str "have",Space,Str "to",Space,Str "escape",Space,Str "my",Space,Str "apostrophes;",Space,Str "great,",Space,Str "isn't",Space,Str "it?",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "the",Space,Code ("",[],[]) "Foo",Space,Str "module."]
1515,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "bulleted",Space,Str "list:"]
1616,BulletList
1717 [[Para [Str "first",Space,Str "item"]]
tests/tables.haddocknew file+72
@@ -0,0 +1,72 @@
1+Simple table with caption:
2+
3+> Right Left Center Default
4+> ------- ------ -------- ---------
5+> 12 12 12 12
6+> 123 123 123 123
7+> 1 1 1 1
8+>
9+Simple table without caption:
10+
11+> Right Left Center Default
12+> ------- ------ -------- ---------
13+> 12 12 12 12
14+> 123 123 123 123
15+> 1 1 1 1
16+>
17+Simple table indented two spaces:
18+
19+> Right Left Center Default
20+> ------- ------ -------- ---------
21+> 12 12 12 12
22+> 123 123 123 123
23+> 1 1 1 1
24+>
25+Multiline table with caption:
26+
27+> --------------------------------------------------------------
28+> Centered Left Right Default aligned
29+> Header Aligned Aligned
30+> ----------- ---------- ------------ --------------------------
31+> First row 12.0 Example of a row that
32+> spans multiple lines.
33+>
34+> Second row 5.0 Here\'s another one. Note
35+> the blank line between
36+> rows.
37+> --------------------------------------------------------------
38+>
39+Multiline table without caption:
40+
41+> --------------------------------------------------------------
42+> Centered Left Right Default aligned
43+> Header Aligned Aligned
44+> ----------- ---------- ------------ --------------------------
45+> First row 12.0 Example of a row that
46+> spans multiple lines.
47+>
48+> Second row 5.0 Here\'s another one. Note
49+> the blank line between
50+> rows.
51+> --------------------------------------------------------------
52+>
53+Table without column headers:
54+
55+> ----- ----- ----- -----
56+> 12 12 12 12
57+> 123 123 123 123
58+> 1 1 1 1
59+> ----- ----- ----- -----
60+>
61+Multiline table without column headers:
62+
63+> ----------- ---------- ------------ --------------------------
64+> First row 12.0 Example of a row that
65+> spans multiple lines.
66+>
67+> Second row 5.0 Here\'s another one. Note
68+> the blank line between
69+> rows.
70+> ----------- ---------- ------------ --------------------------
71+>
72+
tests/writer.haddocknew file+660
@@ -0,0 +1,660 @@
1+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
2+markdown test suite.
3+
4+--------------
5+
6+= Headers
7+#headers#
8+
9+== Level 2 with an </url embedded link>
10+#level-2-with-an-embedded-link#
11+
12+=== Level 3 with /emphasis/
13+#level-3-with-emphasis#
14+
15+==== Level 4
16+#level-4#
17+
18+===== Level 5
19+#level-5#
20+
21+= Level 1
22+#level-1#
23+
24+== Level 2 with /emphasis/
25+#level-2-with-emphasis#
26+
27+=== Level 3
28+#level-3#
29+
30+with no blank line
31+
32+== Level 2
33+#level-2#
34+
35+with no blank line
36+
37+--------------
38+
39+= Paragraphs
40+#paragraphs#
41+
42+Here’s a regular paragraph.
43+
44+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
45+Because a hard-wrapped line in the middle of a paragraph looked like a list
46+item.
47+
48+Here’s one with a bullet. * criminey.
49+
50+There should be a hard line break
51+here.
52+
53+--------------
54+
55+= Block Quotes
56+#block-quotes#
57+
58+E-mail style:
59+
60+This is a block quote. It is pretty short.
61+
62+Code in a block quote:
63+
64+> sub status {
65+> print "working";
66+> }
67+
68+A list:
69+
70+1. item one
71+2. item two
72+
73+Nested block quotes:
74+
75+nested
76+
77+nested
78+
79+This should not be a block quote: 2 > 1.
80+
81+And a following paragraph.
82+
83+--------------
84+
85+= Code Blocks
86+#code-blocks#
87+
88+Code:
89+
90+> ---- (should be four hyphens)
91+>
92+> sub status {
93+> print "working";
94+> }
95+>
96+> this code block is indented by one tab
97+
98+And:
99+
100+> this code block is indented by two tabs
101+>
102+> These should not be escaped: \$ \\ \> \[ \{
103+
104+--------------
105+
106+= Lists
107+#lists#
108+
109+== Unordered
110+#unordered#
111+
112+Asterisks tight:
113+
114+- asterisk 1
115+- asterisk 2
116+- asterisk 3
117+
118+Asterisks loose:
119+
120+- asterisk 1
121+
122+- asterisk 2
123+
124+- asterisk 3
125+
126+Pluses tight:
127+
128+- Plus 1
129+- Plus 2
130+- Plus 3
131+
132+Pluses loose:
133+
134+- Plus 1
135+
136+- Plus 2
137+
138+- Plus 3
139+
140+Minuses tight:
141+
142+- Minus 1
143+- Minus 2
144+- Minus 3
145+
146+Minuses loose:
147+
148+- Minus 1
149+
150+- Minus 2
151+
152+- Minus 3
153+
154+== Ordered
155+#ordered#
156+
157+Tight:
158+
159+1. First
160+2. Second
161+3. Third
162+
163+and:
164+
165+1. One
166+2. Two
167+3. Three
168+
169+Loose using tabs:
170+
171+1. First
172+
173+2. Second
174+
175+3. Third
176+
177+and using spaces:
178+
179+1. One
180+
181+2. Two
182+
183+3. Three
184+
185+Multiple paragraphs:
186+
187+1. Item 1, graf one.
188+
189+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
190+
191+2. Item 2.
192+
193+3. Item 3.
194+
195+== Nested
196+#nested#
197+
198+- Tab
199+ - Tab
200+ - Tab
201+
202+Here’s another:
203+
204+1. First
205+2. Second:
206+ - Fee
207+ - Fie
208+ - Foe
209+
210+3. Third
211+
212+Same thing but with paragraphs:
213+
214+1. First
215+
216+2. Second:
217+
218+ - Fee
219+ - Fie
220+ - Foe
221+
222+3. Third
223+
224+== Tabs and spaces
225+#tabs-and-spaces#
226+
227+- this is a list item indented with tabs
228+
229+- this is a list item indented with spaces
230+
231+ - this is an example list item indented with tabs
232+
233+ - this is an example list item indented with spaces
234+
235+== Fancy list markers
236+#fancy-list-markers#
237+
238+(2) begins with 2
239+(3) and now 3
240+
241+ with a continuation
242+
243+ iv. sublist with roman numerals, starting with 4
244+ v. more items
245+ (A) a subsublist
246+ (B) a subsublist
247+
248+Nesting:
249+
250+A. Upper Alpha
251+ I. Upper Roman.
252+ (6) Decimal start with 6
253+ c) Lower alpha with paren
254+
255+Autonumbering:
256+
257+1. Autonumber.
258+2. More.
259+ 1. Nested.
260+
261+Should not be a list item:
262+
263+M.A. 2007
264+
265+B. Williams
266+
267+--------------
268+
269+= Definition Lists
270+#definition-lists#
271+
272+Tight using spaces:
273+
274+[apple]
275+ red fruit
276+[orange]
277+ orange fruit
278+[banana]
279+ yellow fruit
280+
281+Tight using tabs:
282+
283+[apple]
284+ red fruit
285+[orange]
286+ orange fruit
287+[banana]
288+ yellow fruit
289+
290+Loose:
291+
292+[apple]
293+ red fruit
294+
295+[orange]
296+ orange fruit
297+
298+[banana]
299+ yellow fruit
300+
301+Multiple blocks with italics:
302+
303+[/apple/]
304+ red fruit
305+
306+ contains seeds, crisp, pleasant to taste
307+
308+[/orange/]
309+ orange fruit
310+
311+ > { orange code block }
312+
313+ orange block quote
314+
315+Multiple definitions, tight:
316+
317+[apple]
318+ red fruit
319+ computer
320+[orange]
321+ orange fruit
322+ bank
323+
324+Multiple definitions, loose:
325+
326+[apple]
327+ red fruit
328+
329+ computer
330+
331+[orange]
332+ orange fruit
333+
334+ bank
335+
336+Blank line after term, indented marker, alternate markers:
337+
338+[apple]
339+ red fruit
340+
341+ computer
342+
343+[orange]
344+ orange fruit
345+
346+ 1. sublist
347+ 2. sublist
348+
349+= HTML Blocks
350+#html-blocks#
351+
352+Simple block on one line:
353+
354+foo
355+
356+And nested without indentation:
357+
358+foo
359+
360+bar
361+
362+Interpreted markdown in a table:
363+
364+This is /emphasized/
365+And this is __strong__
366+Here’s a simple block:
367+
368+foo
369+
370+This should be a code block, though:
371+
372+> <div>
373+> foo
374+> </div>
375+
376+As should this:
377+
378+> <div>foo</div>
379+
380+Now, nested:
381+
382+foo
383+
384+This should just be an HTML comment:
385+
386+Multiline:
387+
388+Code block:
389+
390+> <!-- Comment -->
391+
392+Just plain comment, with trailing spaces on the line:
393+
394+Code:
395+
396+> <hr />
397+
398+Hr’s:
399+
400+--------------
401+
402+= Inline Markup
403+#inline-markup#
404+
405+This is /emphasized/, and so /is this/.
406+
407+This is __strong__, and so __is this__.
408+
409+An /</url emphasized link>/.
410+
411+__/This is strong and em./__
412+
413+So is __/this/__ word.
414+
415+__/This is strong and em./__
416+
417+So is __/this/__ word.
418+
419+This is code: @>@, @$@, @\\@, @\\$@, @\<html>@.
420+
421+~~This is /strikeout/.~~
422+
423+Superscripts: abcd a/hello/ ahello there.
424+
425+Subscripts: H2O, H23O, Hmany of themO.
426+
427+These should not be superscripts or subscripts, because of the unescaped
428+spaces: a^b c^d, a~b c~d.
429+
430+--------------
431+
432+= Smart quotes, ellipses, dashes
433+#smart-quotes-ellipses-dashes#
434+
435+“Hello,” said the spider. “‘Shelob’ is my name.”
436+
437+‘A’, ‘B’, and ‘C’ are letters.
438+
439+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
440+
441+‘He said, “I want to go.”’ Were you alive in the 70’s?
442+
443+Here is some quoted ‘@code@’ and a
444+“<http://example.com/?foo=1&bar=2 quoted link>”.
445+
446+Some dashes: one—two — three—four — five.
447+
448+Dashes between numbers: 5–7, 255–66, 1987–1999.
449+
450+Ellipses…and…and….
451+
452+--------------
453+
454+= LaTeX
455+#latex#
456+
457+-
458+- 2 + 2 = 4
459+- /x/ ∈ /y/
460+- /α/ ∧ /ω/
461+- 223
462+- /p/-Tree
463+- Here’s some display math:
464+ $$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}$$
465+- Here’s one that has a line break in it: /α/ + /ω/ × /x/2.
466+
467+These shouldn’t be math:
468+
469+- To get the famous equation, write @$e = mc^2$@.
470+- $22,000 is a /lot/ of money. So is $34,000. (It worked if “lot” is
471+ emphasized.)
472+- Shoes ($20) and socks ($5).
473+- Escaped @$@: $73 /this should be emphasized/ 23$.
474+
475+Here’s a LaTeX table:
476+
477+--------------
478+
479+= Special Characters
480+#special-characters#
481+
482+Here is some unicode:
483+
484+- I hat: Î
485+- o umlaut: ö
486+- section: §
487+- set membership: ∈
488+- copyright: ©
489+
490+AT&T has an ampersand in their name.
491+
492+AT&T is another way to write it.
493+
494+This & that.
495+
496+4 \< 5.
497+
498+6 > 5.
499+
500+Backslash: \\
501+
502+Backtick: \`
503+
504+Asterisk: *
505+
506+Underscore: _
507+
508+Left brace: {
509+
510+Right brace: }
511+
512+Left bracket: [
513+
514+Right bracket: ]
515+
516+Left paren: (
517+
518+Right paren: )
519+
520+Greater-than: >
521+
522+Hash: #
523+
524+Period: .
525+
526+Bang: !
527+
528+Plus: +
529+
530+Minus: -
531+
532+--------------
533+
534+= Links
535+#links#
536+
537+== Explicit
538+#explicit#
539+
540+Just a </url/ URL>.
541+
542+</url/ URL and title>.
543+
544+</url/ URL and title>.
545+
546+</url/ URL and title>.
547+
548+</url/ URL and title>
549+
550+</url/ URL and title>
551+
552+</url/with_underscore with_underscore>
553+
554+<mailto:nobody@nowhere.net Email link>
555+
556+< Empty>.
557+
558+== Reference
559+#reference#
560+
561+Foo </url/ bar>.
562+
563+Foo </url/ bar>.
564+
565+Foo </url/ bar>.
566+
567+With </url/ embedded [brackets]>.
568+
569+</url/ b> by itself should be a link.
570+
571+Indented </url once>.
572+
573+Indented </url twice>.
574+
575+Indented </url thrice>.
576+
577+This should [not][] be a link.
578+
579+> [not]: /url
580+
581+Foo </url/ bar>.
582+
583+Foo </url/ biz>.
584+
585+== With ampersands
586+#with-ampersands#
587+
588+Here’s a <http://example.com/?foo=1&bar=2 link with an ampersand in the URL>.
589+
590+Here’s a link with an amersand in the link text: <http://att.com/ AT&T>.
591+
592+Here’s an </script?foo=1&bar=2 inline link>.
593+
594+Here’s an </script?foo=1&bar=2 inline link in pointy braces>.
595+
596+== Autolinks
597+#autolinks#
598+
599+With an ampersand: <http://example.com/?foo=1&bar=2>
600+
601+- In a list?
602+- <http://example.com/>
603+- It should.
604+
605+An e-mail address: <mailto:nobody@nowhere.net nobody\@nowhere.net>
606+
607+Blockquoted: <http://example.com/>
608+
609+Auto-links should not occur here: @\<http:\/\/example.com\/>@
610+
611+> or here: <http://example.com/>
612+
613+--------------
614+
615+= Images
616+#images#
617+
618+From “Voyage dans la Lune” by Georges Melies (1902):
619+
620+<<lalune.jpg lalune>>
621+
622+Here is a movie <<movie.jpg movie>> icon.
623+
624+--------------
625+
626+= Footnotes
627+#footnotes#
628+
629+Here is a footnote reference,<#notes [1]> and another.<#notes [2]> This should
630+/not/ be a footnote reference, because it contains a space.[^my note] Here is
631+an inline note.<#notes [3]>
632+
633+Notes can go in quotes.<#notes [4]>
634+
635+1. And in list items.<#notes [5]>
636+
637+This paragraph should not be part of the note, as it is not indented.
638+
639+#notes#
640+
641+1. Here is the footnote. It can go anywhere after the footnote reference. It
642+ need not be placed at the end of the document.
643+
644+2. Here’s the long note. This one contains multiple blocks.
645+
646+ Subsequent blocks are indented to show that they belong to the footnote
647+ (as with list items).
648+
649+ > { <code> }
650+
651+ If you want, you can indent every line, but you can also be lazy and just
652+ indent the first line of each block.
653+
654+3. This is /easier/ to type. Inline notes may contain
655+ <http://google.com links> and @]@ verbatim characters, as well as
656+ [bracketed text].
657+
658+4. In quote.
659+
660+5. In list.