diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Old.hs | 3 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 28 | ||||
-rw-r--r-- | test/Tests/Writers/Docx.hs | 23 | ||||
-rw-r--r-- | test/command/3681.md | 27 | ||||
-rw-r--r-- | test/command/3803.md | 10 | ||||
-rw-r--r-- | test/command/3804.md | 6 | ||||
-rw-r--r-- | test/command/html-read-figure.md | 45 | ||||
-rw-r--r-- | test/command/ifstrequal.md | 10 | ||||
-rw-r--r-- | test/command/macros.md | 17 | ||||
-rw-r--r-- | test/markdown-reader-more.native | 1 | ||||
-rw-r--r-- | test/tikiwiki-reader.native | 130 | ||||
-rw-r--r-- | test/tikiwiki-reader.tikiwiki | 148 |
12 files changed, 440 insertions, 8 deletions
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index b807719bc..c4dd4d322 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -137,6 +137,9 @@ tests = [ testGroup "markdown" , testGroup "twiki" [ test "reader" ["-r", "twiki", "-w", "native", "-s"] "twiki-reader.twiki" "twiki-reader.native" ] + , testGroup "tikiwiki" + [ test "reader" ["-r", "tikiwiki", "-w", "native", "-s"] + "tikiwiki-reader.tikiwiki" "tikiwiki-reader.native" ] , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f) [ "opendocument" , "context" , "texinfo", "icml", "tei" , "man" , "plain" , "rtf", "org", "asciidoc", "zimwiki" diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index fe0a59992..a069bb972 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -314,5 +314,33 @@ tests = , para "* Bar" ] ] + , "List inside a tag" =: + T.unlines + [ "<quote>" + , " 1. First" + , "" + , " 2. Second" + , "" + , " 3. Third" + , "</quote>" + ] =?> + blockQuote (orderedListWith (1, Decimal, Period) [ para "First" + , para "Second" + , para "Third" + ]) + -- Amusewiki requires block tags to be on separate lines, + -- but Emacs Muse allows them to be on the same line as contents. + , "List inside an inline tag" =: + T.unlines + [ "<quote> 1. First" + , "" + , " 2. Second" + , "" + , " 3. Third</quote>" + ] =?> + blockQuote (orderedListWith (1, Decimal, Period) [ para "First" + , para "Second" + , para "Third" + ]) ] ] diff --git a/test/Tests/Writers/Docx.hs b/test/Tests/Writers/Docx.hs index 215952893..ec147604c 100644 --- a/test/Tests/Writers/Docx.hs +++ b/test/Tests/Writers/Docx.hs @@ -6,6 +6,7 @@ import Tests.Helpers import Text.Pandoc.Class (runIOorExplode) import Text.Pandoc.Definition import Text.Pandoc.Options +import Text.Pandoc.Walk import Text.Pandoc.Readers.Docx import Text.Pandoc.Readers.Native import Text.Pandoc.Writers.Docx @@ -19,16 +20,22 @@ compareOutput :: Options -> FilePath -> FilePath -> IO (Pandoc, Pandoc) -compareOutput opts nativeFileIn nativeFileOut = do +compareOutput (wopts, ropts) nativeFileIn nativeFileOut = do nf <- UTF8.toText <$> BS.readFile nativeFileIn nf' <- UTF8.toText <$> BS.readFile nativeFileOut - let wopts = fst opts - df <- runIOorExplode $ do - d <- readNative def nf - writeDocx wopts{writerUserDataDir = Just (".." </> "data")} d - df' <- runIOorExplode (readNative def nf') - p <- runIOorExplode $ readDocx (snd opts) df - return (p, df') + runIOorExplode $ do + roundtripped <- readNative def nf >>= + writeDocx wopts{writerUserDataDir = Just (".." </> "data")} >>= + readDocx ropts + orig <- readNative def nf' + return (walk fixImages roundtripped, walk fixImages orig) + +-- make all image filenames "image", since otherwise round-trip +-- tests fail because of different behavior of Data.Unique in +-- different ghc versions... +fixImages :: Inline -> Inline +fixImages (Image attr alt (_,tit)) = Image attr alt ("image",tit) +fixImages x = x testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO TestTree testCompareWithOptsIO opts name nativeFileIn nativeFileOut = do diff --git a/test/command/3681.md b/test/command/3681.md new file mode 100644 index 000000000..d0805e820 --- /dev/null +++ b/test/command/3681.md @@ -0,0 +1,27 @@ +``` +% pandoc -f latex -t native +\newcommand{\cicd}{CI/CD\xspace} + +Software developers create \cicd pipelines to… Following issue can be resolved by \cicd: +^D +[Para [Str "Software",Space,Str "developers",Space,Str "create",Space,Str "CI/CD",Space,Str "pipelines",Space,Str "to\8230",Space,Str "Following",Space,Str "issue",Space,Str "can",Space,Str "be",Space,Str "resolved",Space,Str "by",Space,Str "CI/CD:"]] +``` + +``` +% pandoc -f latex -t native +\newcommand{\cicd}{CI/CD\xspace} + +\cicd\footnote{\url{https://en.wikipedia.org/wiki/CI/CD}} is awesome. +^D +[Para [Str "CI/CD",Note [Para [Link ("",[],[]) [Str "https://en.wikipedia.org/wiki/CI/CD"] ("https://en.wikipedia.org/wiki/CI/CD","")]],Space,Str "is",Space,Str "awesome."]] +``` + +``` +% pandoc -f latex -t native +\newcommand{\cicd}{CI/CD\xspace} +\newcommand{\pipeline}{pipeline\xspace} + +\cicd\pipeline. +^D +[Para [Str "CI/CD",Space,Str "pipeline."]] +``` diff --git a/test/command/3803.md b/test/command/3803.md new file mode 100644 index 000000000..a2e60359d --- /dev/null +++ b/test/command/3803.md @@ -0,0 +1,10 @@ +``` +% pandoc -f markdown+raw_tex -t latex +\begin{blah*} +*ok* +\end{blah*} +^D +\begin{blah*} +*ok* +\end{blah*} +``` diff --git a/test/command/3804.md b/test/command/3804.md new file mode 100644 index 000000000..c13c2ef42 --- /dev/null +++ b/test/command/3804.md @@ -0,0 +1,6 @@ +``` +% pandoc -t native +\titleformat{\chapter}[display]{\normalfont\large\bfseries}{第\thechapter{}章}{20pt}{\Huge} +^D +[RawBlock (Format "latex") "\\titleformat{\\chapter}[display]{\\normalfont\\large\\bfseries}{\31532\\thechapter{}\31456}{20pt}{\\Huge}"] +``` diff --git a/test/command/html-read-figure.md b/test/command/html-read-figure.md new file mode 100644 index 000000000..9c604c706 --- /dev/null +++ b/test/command/html-read-figure.md @@ -0,0 +1,45 @@ +``` +% pandoc -f html -t native +<figure> + <img src="foo.png" title="voyage"> + <figcaption>bar</figcaption> +</figure> +^D +[Para [Image ("",[],[]) [Str "bar"] ("foo.png","fig:voyage")]] +``` + +``` +% pandoc -f html -t native +<figure> + <figcaption>bar</figcaption> + <img src="foo.png" title="voyage"> +</figure> +^D +[Para [Image ("",[],[]) [Str "bar"] ("foo.png","fig:voyage")]] +``` + +``` +% pandoc -f html -t native +<figure> + <img src="foo.png" title="voyage"> +</figure> +^D +[Para [Image ("",[],[]) [] ("foo.png","fig:voyage")]] +``` + +``` +% pandoc -f html -t native +<figure> + <p><img src="foo.png" title="voyage"></p> + <figcaption>bar</figcaption> +</figure> +^D +[Para [Image ("",[],[]) [Str "bar"] ("foo.png","fig:voyage")]] +``` + +``` +% pandoc -f html -t native +<figure><img src="foo.png" title="voyage" alt="this is ignored"><figcaption>bar <strong>baz</strong></figcaption></figure> +^D +[Para [Image ("",[],[]) [Str "bar",Space,Strong [Str "baz"]] ("foo.png","fig:voyage")]] +``` diff --git a/test/command/ifstrequal.md b/test/command/ifstrequal.md new file mode 100644 index 000000000..4ad04d2e1 --- /dev/null +++ b/test/command/ifstrequal.md @@ -0,0 +1,10 @@ +``` +% pandoc -f latex -t native +\ifstrequal{a}{b}{yes}{\emph{no}} +\newcommand{\h}[1]{\ifstrequal{#1}{a}{\'a}{#1}} +\h{a} +\h{b} +^D +[Para [Emph [Str "no"]] +,Para [Str "\225",SoftBreak,Str "b"]] +``` diff --git a/test/command/macros.md b/test/command/macros.md new file mode 100644 index 000000000..055c86d25 --- /dev/null +++ b/test/command/macros.md @@ -0,0 +1,17 @@ +``` +% pandoc -f markdown+latex_macros -t markdown +\newcommand{\my}{\phi} +$\my+\my$ +^D +\newcommand{\my}{\phi} +$\phi+\phi$ +``` + +``` +% pandoc -f markdown-latex_macros -t markdown +\newcommand{\my}{\phi} +$\my+\my$ +^D +\newcommand{\my}{\phi} +$\my+\my$ +``` diff --git a/test/markdown-reader-more.native b/test/markdown-reader-more.native index 5d63a21de..a24417ffe 100644 --- a/test/markdown-reader-more.native +++ b/test/markdown-reader-more.native @@ -56,6 +56,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S ,OrderedList (3,Example,TwoParens) [[Plain [Str "Third",Space,Str "example."]]] ,Header 2 ("macros",[],[]) [Str "Macros"] +,RawBlock (Format "latex") "\\newcommand{\\tuple}[1]{\\langle #1 \\rangle}" ,Para [Math InlineMath "\\langle x,y \\rangle"] ,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"] ,Para [Link ("",[],[]) [Str "Fum"] ("/fum","")] diff --git a/test/tikiwiki-reader.native b/test/tikiwiki-reader.native new file mode 100644 index 000000000..2ab053217 --- /dev/null +++ b/test/tikiwiki-reader.native @@ -0,0 +1,130 @@ +Pandoc (Meta {unMeta = fromList []}) +[Header 1 ("header",[],[]) [Str "header"] +,Header 2 ("header-level-two",[],[]) [Str "header",Space,Str "level",Space,Str "two"] +,Header 3 ("header-level-3",[],[]) [Str "header",Space,Str "level",Space,Str "3"] +,Header 4 ("header-_level_-four",[],[]) [Str "header",Space,Str "_level_",Space,Str "four"] +,Header 5 ("header-level-5",[],[]) [Str "header",Space,Str "level",Space,Str "5"] +,Header 6 ("header-level-6",[],[]) [Str "header",Space,Str "level",Space,Str "6"] +,Para [Str "!!!!!!!",Space,Str "not",Space,Str "a",Space,Str "header"] +,Para [Str "--++",Space,Str "not",Space,Str "a",Space,Str "header"] +,Header 1 ("emph-and-strong",[],[]) [Str "emph",Space,Str "and",Space,Str "strong"] +,Para [Emph [Str "emph"],Space,Strong [Str "strong"]] +,Para [Emph [Strong [Str "strong",Space,Str "and",Space,Str "emph",Space,Str "1"]]] +,Para [Strong [Emph [Str "strong",Space,Str "and",Space,Str "emph",Space,Str "2"]]] +,Para [Strong [Emph [Str "emph",Space,Str "inside"],Space,Str "strong"]] +,Para [Strong [Str "strong",Space,Str "with",Space,Emph [Str "emph"]]] +,Para [Emph [Strong [Str "strong",Space,Str "inside"],Space,Str "emph"]] +,Header 1 ("horizontal-rule",[],[]) [Str "horizontal",Space,Str "rule"] +,Para [Str "top"] +,HorizontalRule +,Para [Str "bottom"] +,HorizontalRule +,Header 1 ("nop",[],[]) [Str "nop"] +,Para [Str "__not emph__"] +,Header 1 ("entities",[],[]) [Str "entities"] +,Para [Str "hi",Space,Str "&",Space,Str "low"] +,Para [Str "hi",Space,Str "&",Space,Str "low"] +,Para [Str "G\246del"] +,Para [Str "\777\2730"] +,Header 1 ("linebreaks",[],[]) [Str "linebreaks"] +,Para [Str "hi",LineBreak,Str "there"] +,Para [Str "hi",LineBreak,Str "there"] +,Header 1 ("inline-code",[],[]) [Str "inline",Space,Str "code"] +,Para [Code ("",[],[]) "*\8594*",Space,Code ("",[],[]) "typed",Space,Code ("",[],[]) ">>="] +,Header 1 ("code-blocks",[],[]) [Str "code",Space,Str "blocks"] +,CodeBlock ("",[],[]) "\ncase xs of\n (_:_) -> reverse xs\n [] -> ['*']\n" +,CodeBlock ("",["haskell"],[("colors","haskell"),("ln","0")]) "\ncase xs of\n (_:_) -> reverse xs\n [] -> ['*']\n" +,Header 1 ("external-links",[],[]) [Str "external",Space,Str "links"] +,Para [Link ("",[],[]) [Emph [Str "Google"],Space,Str "search",Space,Str "engine"] ("http://google.com","")] +,Para [Link ("",[],[]) [Str "http://pandoc.org"] ("http://pandoc.org","")] +,Para [Link ("",[],[]) [Str "http://google.com"] ("http://google.com",""),Space,Link ("",[],[]) [Str "http://yahoo.com"] ("http://yahoo.com","")] +,Para [Link ("",[],[]) [Str "email",Space,Str "me"] ("mailto:info@example.org","")] +,Para [Str "http://google.com"] +,Para [Str "info@example.org"] +,Header 1 ("lists",[],[]) [Str "lists"] +,BulletList + [[Plain [Str "Start",Space,Str "each",Space,Str "line",Space]] + ,[Plain [Str "with",Space,Str "an",Space,Str "asterisk",Space,Str "(*).",Space] + ,BulletList + [[Plain [Str "More",Space,Str "asterisks",Space,Str "gives",Space,Str "deeper",Space] + ,BulletList + [[Plain [Str "and",Space,Str "deeper",Space,Str "levels.",Space]]]]]] + ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels.",Space]] + ,[Plain [Str "Continuations",Space,Str "are",Space,Str "also",Space,Str "possible",Space] + ,BulletList + [[Plain [Str "and",Space,Str "do",Space,Str "not",Space,Str "break",Space,Str "the",Space,Str "list",Space,Str "flow",Space]]]] + ,[Plain [Str "Level",Space,Str "one",Space]]] +,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "ends",Space,Str "the",Space,Str "list."] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Start",Space,Str "each",Space,Str "line",Space]] + ,[Plain [Str "with",Space,Str "a",Space,Str "number",Space,Str "(1.).",Space] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "More",Space,Str "number",Space,Str "signs",Space,Str "gives",Space,Str "deeper",Space] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "and",Space,Str "deeper",Space]] + ,[Plain [Str "levels.",Space]]]]]] + ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels.",Space]] + ,[Plain [Str "Blank",Space,Str "lines",Space]]] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "end",Space,Str "the",Space,Str "list",Space,Str "and",Space,Str "start",Space,Str "another.",Space]]] +,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "also",Space,Str "ends",Space,Str "the",Space,Str "list."] +,DefinitionList + [([Str "item",Space,Str "1"], + [[Plain [Str "definition",Space,Str "1",Space]]]) + ,([Str "item",Space,Str "2"], + [[Plain [Str "definition",Space,Str "2-1",Space,Str "definition",Space,Str "2-2",Space]]]) + ,([Str "item",Space,Emph [Str "3"]], + [[Plain [Str "definition",Space,Emph [Str "3"],Space]]])] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "one",Space]] + ,[Plain [Str "two",Space] + ,BulletList + [[Plain [Str "two",Space,Str "point",Space,Str "one",Space]] + ,[Plain [Str "two",Space,Str "point",Space,Str "two",Space]]]] + ,[Plain [Str "three",Space]] + ,[Plain [Str "four",Space]] + ,[Plain [Str "five",Space] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "five",Space,Str "sub",Space,Str "1",Space] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "five",Space,Str "sub",Space,Str "1",Space,Str "sub",Space,Str "1",Space]]]] + ,[Plain [Str "five",Space,Str "sub",Space,Str "2",Space]]]]] +,Header 1 ("tables",[],[]) [Str "tables"] +,Table [] [AlignDefault,AlignDefault] [0.0,0.0] + [[Plain [Str ""]] + ,[Plain [Str ""]]] + [[[Plain [Str "Orange"]] + ,[Plain [Str "Apple"]]] + ,[[Plain [Str "Bread"]] + ,[Plain [Str "Pie"]]] + ,[[Plain [Str "Butter"]] + ,[Plain [Str "Ice",Space,Str "cream"]]]] +,Table [] [AlignDefault,AlignDefault] [0.0,0.0] + [[Plain [Str ""]] + ,[Plain [Str ""]]] + [[[Plain [Str "Orange"]] + ,[Plain [Str "Apple"]]] + ,[[Plain [Str "Bread"]] + ,[Plain [Str "Pie"]]] + ,[[Plain [Strong [Str "Butter"]]] + ,[Plain [Str "Ice",Space,Str "cream"]]]] +,Table [] [AlignDefault,AlignDefault] [0.0,0.0] + [[Plain [Str ""]] + ,[Plain [Str ""]]] + [[[Plain [Str "Orange"]] + ,[Plain [Str "Apple"]]] + ,[[Plain [Str "Bread",LineBreak,LineBreak,Str "and",Space,Str "cheese"]] + ,[Plain [Str "Pie",LineBreak,LineBreak,Strong [Str "apple"],Space,Str "and",Space,Emph [Str "carrot"],Space]]]] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] + [[Plain [Str ""]] + ,[Plain [Str ""]] + ,[Plain [Str ""]]] + [[[Plain [Space,Str "Orange",Space]] + ,[Plain [Space,Str "Apple",Space]] + ,[Plain [Space,Str "more"]]] + ,[[Plain [Space,Str "Bread",Space]] + ,[Plain [Space,Str "Pie",Space]] + ,[Plain [Space,Str "more"]]] + ,[[Plain [Space,Str "Butter",Space]] + ,[Plain [Space,Str "Ice",Space,Str "cream",Space]] + ,[Plain [Space,Str "and",Space,Str "more",Space]]]]] diff --git a/test/tikiwiki-reader.tikiwiki b/test/tikiwiki-reader.tikiwiki new file mode 100644 index 000000000..d1971feb1 --- /dev/null +++ b/test/tikiwiki-reader.tikiwiki @@ -0,0 +1,148 @@ +! header + +!! header level two + +!!! header level 3 + +!!!! header _level_ four + +!!!!! header level 5 + +!!!!!! header level 6 + +!!!!!!! not a header + + --++ not a header + +! emph and strong + +''emph'' __strong__ + +''__strong and emph 1__'' + +__''strong and emph 2''__ + +__''emph inside'' strong__ + +__strong with ''emph''__ + +''__strong inside__ emph'' + +! horizontal rule + +top +---- +bottom + +---- + +! nop + +~np~__not emph__~/np~ + +! entities + +hi & low + +hi & low + +Gödel + +̉પ + +! linebreaks + +hi%%%there + +hi%%% +there + +! inline code + +-+*→*+- -+typed+- -+>>=+- + +! code blocks + +{CODE()} +case xs of + (_:_) -> reverse xs + [] -> ['*'] +{CODE} + +{CODE(colors="haskell" ln=0)} +case xs of + (_:_) -> reverse xs + [] -> ['*'] +{CODE} + +! external links + +[http://google.com|''Google'' search engine] + +[http://pandoc.org] + +[http://google.com] [http://yahoo.com] + +[mailto:info@example.org|email me] + +http://google.com + +info@example.org + +! lists + +* Start each line +* with an asterisk (*). +** More asterisks gives deeper +*** and deeper levels. +* Line breaks%%%don't break levels. +* Continuations ++ are also possible +** and do not break the list flow +* Level one +Any other start ends the list. + +# Start each line +# with a number (1.). +## More number signs gives deeper +### and deeper +### levels. +# Line breaks%%%don't break levels. +# Blank lines + +# end the list and start another. +Any other start also +ends the list. + +;item 1: definition 1 +;item 2: definition 2-1 ++ definition 2-2 +;item ''3'': definition ''3'' + +# one +# two +** two point one +** two point two +# three +# four +# five +## five sub 1 +### five sub 1 sub 1 +## five sub 2 + +! tables + +||Orange|Apple +Bread|Pie +Butter|Ice cream|| + +||Orange|Apple +Bread|Pie +__Butter__|Ice cream|| + +||Orange|Apple +Bread%%%%%%and cheese|Pie%%%%%%__apple__ and ''carrot'' || + +|| Orange | Apple | more + Bread | Pie | more + Butter | Ice cream | and more || |