From 7741cdbf04f93875e6cd2051a6778c2ca35b5e40 Mon Sep 17 00:00:00 2001 From: Yan Pas Date: Wed, 17 Oct 2018 00:21:52 +0300 Subject: [PATCH] added old-style test --- src/Text/Pandoc/Readers/Man.hs | 1 + test/Tests/Old.hs | 4 + test/Tests/Readers/Man.hs | 2 +- test/man-reader.man | 189 +++++++++++++++++++++++++++++++++ test/man-reader.native | 94 ++++++++++++++++ 5 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 test/man-reader.man create mode 100644 test/man-reader.native diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index d04718fc7..1ffdd1f91 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -73,6 +73,7 @@ type Font = Set FontKind type RoffStr = (String, Font) +-- TODO parse tables (see man tbl) data ManToken = MStr RoffStr | MLine [RoffStr] | MMaybeLink String diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index b426ffd07..842e0f656 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -171,6 +171,10 @@ tests = [ testGroup "markdown" , test "tables" ["-f", "native", "-t", "../data/sample.lua"] "tables.native" "tables.custom" ] + , testGroup "man" + [ test "reader" ["-r", "man", "-w", "native", "-s"] + "man-reader.man" "man-reader.native" + ] ] -- makes sure file is fully closed after reading diff --git a/test/Tests/Readers/Man.hs b/test/Tests/Readers/Man.hs index 4d8e13fb1..9dbfbab4d 100644 --- a/test/Tests/Readers/Man.hs +++ b/test/Tests/Readers/Man.hs @@ -73,7 +73,7 @@ tests = [ =?> orderedListWith (1,UpperAlpha,DefaultDelim) [plain $ str "first", plain $ str "second"] , "nested" =: ".IP\nfirst\n.RS\n.IP\n1a\n.IP\n1b\n.RE" - =?> fromList [BulletList [[Plain [Str "first"],BulletList [[Plain [Str "1a"]],[Plain [Str "1b"]]]]]] + =?> bulletList [(plain $ str "first") <> (bulletList [plain $ str "1a", plain $ str "1b"])] ], testGroup "CodeBlocks" [ "cb1"=: diff --git a/test/man-reader.man b/test/man-reader.man new file mode 100644 index 000000000..4f3395051 --- /dev/null +++ b/test/man-reader.man @@ -0,0 +1,189 @@ +.TH "Pandoc Man tests" "" "Oct 17, 2018" "" "" +.PP +This is a set of tests for pandoc. +.PP + * * * * * +.SH Headers +.SH Level 1 +.SS Level 2 + + * * * * * +.SH Paragraphs +.PP +Here's a regular paragraph. +.PP +Another paragraph +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. +.PP +There should be a hard line break +.PD 0 +.P +.PD +here. +.PP + * * * * * +.SH Block Quotes +Code in a block quote: +.IP +.nf +\f[C] +sub\ status\ { +\ \ \ \ print\ "working"; +} +\f[] +.fi +.PP +A list: +.IP "1." 3 +item one +.IP "2." 3 +item two +.PP +.SH Code Blocks +.PP +Code: +.IP +.nf +\f[C] +\-\-\-\-\ (should\ be\ four\ hyphens) + +sub\ status\ { +\ \ \ \ print\ "working"; +} + +\f[] +.fi +.PP +And: +.IP +.nf +\f[C] +\tthis\ code\ line is\ indented\ by\ one\ tab + +These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{ +\f[] +.fi +.PP + * * * * * +.SH Lists +.SS Unordered +.PP +Asterisks: +.IP \[bu] 2 +asterisk 1 +.IP \[bu] 2 +asterisk 2 +.IP \[bu] 2 +asterisk 3 +.PP +.SS Ordered +.IP "1." 3 +First +.IP "2." 3 +Second +.IP "3." 3 +Third +.PP +.SS Nested +.IP \[bu] 2 +Tab +.RS 2 +.IP \[bu] 2 +Tab +.RS 2 +.IP \[bu] 2 +Tab +.RE +.RE +.PP +Here's another: +.IP "1." 3 +First +.IP "2." 3 +Second: +.RS 4 +.IP \[bu] 2 +Fee +.IP \[bu] 2 +Fie +.IP \[bu] 2 +Foe +.RE +.IP "3." 3 +Third +.PP +Same thing: +.IP "1." 3 +First +.IP "2." 3 +Second: +.RS 4 +.IP \[bu] 2 +Fee +.IP \[bu] 2 +Fie +.IP \[bu] 2 +Foe +.RE +.IP "3." 3 +Third +.SS different styles: +.IP "A." 3 +Upper Alpha +.RS 4 +.IP "I." 3 +Upper Roman. +.RS 4 +.IP "(6)" 4 +Decimal start with 6 +.RS 4 +.IP "c)" 3 +Lower alpha with paren +.RE +.RE +.RE +.PP + * * * * * +.SH Special Characters +AT&T has an ampersand in their name. +.PP +4 < 5. +.PP +6 > 5. +.PP +Backslash: \\ +.PP +Backtick: ` +.PP +Asterisk: * +.PP +Underscore: _ +.PP +Left brace: { +.PP +Right brace: } +.PP +Left bracket: [ +.PP +Right bracket: ] +.PP +Left paren: ( +.PP +Right paren: ) +.PP +Greater\-than: > +.PP +Hash: # +.PP +Period: . +.PP +Bang: ! +.PP +Plus: + +.PP +Minus: \- +.PP diff --git a/test/man-reader.native b/test/man-reader.native new file mode 100644 index 000000000..1fa010bd6 --- /dev/null +++ b/test/man-reader.native @@ -0,0 +1,94 @@ +Pandoc (Meta {unMeta = fromList [("title",MetaString "Pandoc Man tests")]}) +[Header 1 ("",[],[]) [Str "Pandoc Man tests"] +,Para [Str "This is a set of tests for pandoc."] +,Para [Str " * * * * *"] +,Header 2 ("",[],[]) [Str "Headers"] +,Header 2 ("",[],[]) [Str "Level",Space,Str "1"] +,Header 3 ("",[],[]) [Str "Level",Space,Str "2"] +,Para [Str " * * * * *"] +,Header 2 ("",[],[]) [Str "Paragraphs"] +,Para [Str "Here's a regular paragraph."] +,Para [Str "Another paragraph",Space,Str "In Markdown 1.0.0 and earlier.",Space,Str "Version 8.",Space,Str "This line turns into a list item.",Space,Str "Because a hard-wrapped line in the middle of a paragraph looked like a list",Space,Str "item."] +,Para [Str "There should be a hard line break"] +,Para [Str "here."] +,Para [Str " * * * * *"] +,Header 2 ("",[],[]) [Str "Block",Space,Str "Quotes"] +,Para [Str "Code in a block quote:"] +,CodeBlock ("",[],[]) "\nsub status {\n print \"working\";\n}\n" +,Para [Str "A list:"] +,OrderedList (1,Decimal,DefaultDelim) + [[Plain [Str "item one"]] + ,[Plain [Str "item two"]]] +,Header 2 ("",[],[]) [Str "Code",Space,Str "Blocks"] +,Para [Str "Code:"] +,CodeBlock ("",[],[]) "\n---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\n" +,Para [Str "And:"] +,CodeBlock ("",[],[]) "\n\tthis code line is indented by one tab\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{\n" +,Para [Str " * * * * *"] +,Header 2 ("",[],[]) [Str "Lists"] +,Header 3 ("",[],[]) [Str "Unordered"] +,Para [Str "Asterisks:"] +,BulletList + [[Plain [Str "",Space,Str "asterisk 1"]] + ,[Plain [Str "",Space,Str "asterisk 2"]] + ,[Plain [Str "",Space,Str "asterisk 3"]]] +,Header 3 ("",[],[]) [Str "Ordered"] +,OrderedList (1,Decimal,DefaultDelim) + [[Plain [Str "First"]] + ,[Plain [Str "Second"]] + ,[Plain [Str "Third"]]] +,Header 3 ("",[],[]) [Str "Nested"] +,BulletList + [[Plain [Str "",Space,Str "Tab"] + ,BulletList + [[Plain [Str "",Space,Str "Tab"] + ,BulletList + [[Plain [Str "",Space,Str "Tab"]]]]]]] +,Para [Str "Here's another:"] +,OrderedList (1,Decimal,DefaultDelim) + [[Plain [Str "First"]] + ,[Plain [Str "Second:"] + ,BulletList + [[Plain [Str "",Space,Str "Fee"]] + ,[Plain [Str "",Space,Str "Fie"]] + ,[Plain [Str "",Space,Str "Foe"]]]] + ,[Plain [Str "Third"]]] +,Para [Str "Same thing:"] +,OrderedList (1,Decimal,DefaultDelim) + [[Plain [Str "First"]] + ,[Plain [Str "Second:"] + ,BulletList + [[Plain [Str "",Space,Str "Fee"]] + ,[Plain [Str "",Space,Str "Fie"]] + ,[Plain [Str "",Space,Str "Foe"]]]] + ,[Plain [Str "Third"]]] +,Header 3 ("",[],[]) [Str "different",Space,Str "styles:"] +,OrderedList (1,UpperAlpha,DefaultDelim) + [[Plain [Str "Upper Alpha"] + ,OrderedList (1,UpperAlpha,DefaultDelim) + [[Plain [Str "Upper Roman."] + ,BulletList + [[Plain [Str "(6)",Space,Str "Decimal start with 6"] + ,OrderedList (1,LowerAlpha,DefaultDelim) + [[Plain [Str "Lower alpha with paren"]]]]]]]]] +,Para [Str " * * * * *"] +,Header 2 ("",[],[]) [Str "Special",Space,Str "Characters"] +,Para [Str "AT&T has an ampersand in their name."] +,Para [Str "4 < 5."] +,Para [Str "6 > 5."] +,Para [Str "Backslash: \\"] +,Para [Str "Backtick: `"] +,Para [Str "Asterisk: *"] +,Para [Str "Underscore: _"] +,Para [Str "Left brace: {"] +,Para [Str "Right brace: }"] +,Para [Str "Left bracket: ["] +,Para [Str "Right bracket: ]"] +,Para [Str "Left paren: ("] +,Para [Str "Right paren: )"] +,Para [Str "Greater-than: >"] +,Para [Str "Hash: #"] +,Para [Str "Period: ."] +,Para [Str "Bang: !"] +,Para [Str "Plus: +"] +,Para [Str "Minus: -"]]