diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Lua.hs | 11 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 26 | ||||
-rw-r--r-- | test/Tests/Writers/Muse.hs | 5 | ||||
-rw-r--r-- | test/command/4171.md | 9 | ||||
-rw-r--r-- | test/lua/test-pandoc-utils.lua | 69 | ||||
-rw-r--r-- | test/tables.jats | 368 |
6 files changed, 212 insertions, 276 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 4f14a834b..0e76249fe 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -91,6 +91,17 @@ tests = map (localOption (QuickCheckTests 20)) "attr-test.lua" (doc $ divWith ("", [], kv_before) (para "nil")) (doc $ divWith ("", [], kv_after) (para "nil")) + + , testCase "Test module pandoc.utils" $ + assertFilterConversion "pandoc.utils doesn't work as expected." + "test-pandoc-utils.lua" + (doc $ para "doesn't matter") + (doc $ mconcat [ plain (str "sha1: OK") + , plain (str "pipe: OK") + , plain (str "failing pipe: OK") + , plain (str "read: OK") + , plain (str "failing read: OK") + ]) ] assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 41d1d9710..abd230c8c 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -455,6 +455,18 @@ tests = , "</quote>" ] =?> blockQuote (para "* Hi") + , "Headers consume anchors" =: + T.unlines [ "** Foo" + , "#bar" + ] =?> + headerWith ("bar",[],[]) 2 "Foo" + , "Headers don't consume anchors separated with a blankline" =: + T.unlines [ "** Foo" + , "" + , "#bar" + ] =?> + header 2 "Foo" <> + para (spanWith ("bar", [], []) mempty) ] , testGroup "Directives" [ "Title" =: @@ -505,6 +517,20 @@ tests = ] =?> para (text "Start recursion here" <> note (para "Recursion continues here[1]")) + , "No zero footnotes" =: + T.unlines [ "Here is a footnote[0]." + , "" + , "[0] Footnote contents" + ] =?> + para "Here is a footnote[0]." <> + para "[0] Footnote contents" + , "Footnotes can't start with zero" =: + T.unlines [ "Here is a footnote[01]." + , "" + , "[01] Footnote contents" + ] =?> + para "Here is a footnote[01]." <> + para "[01] Footnote contents" , testGroup "Multiparagraph footnotes" [ "Amusewiki multiparagraph footnotes" =: T.unlines [ "Multiparagraph[1] footnotes[2]" diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 77e741534..e2e6ba06c 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -234,6 +234,11 @@ tests = [ testGroup "block elements" , "" , "*** Third level" ] + , "heading with ID" =: + headerWith ("bar", [], []) 2 (text "Foo") =?> + unlines [ "** Foo" + , "#bar" + ] ] , "horizontal rule" =: horizontalRule =?> "----" , "escape horizontal rule" =: para (text "----") =?> "<verbatim>----</verbatim>" diff --git a/test/command/4171.md b/test/command/4171.md index 3256d4673..42b4576e3 100644 --- a/test/command/4171.md +++ b/test/command/4171.md @@ -23,3 +23,12 @@ a [fn:1] b ``` + +Similar bug: "-" should not be wrapped: +``` +% pandoc -f org -t org +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - abc +^D +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - +abc +``` diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua new file mode 100644 index 000000000..7354496f9 --- /dev/null +++ b/test/lua/test-pandoc-utils.lua @@ -0,0 +1,69 @@ +utils = require 'pandoc' + +-- SHA1 +------------------------------------------------------------------------ +function test_sha1 () + local ref_hash = '0a0a9f2a6772942557ab5355d76af442f8f65e01' + local hash = utils.sha1 'Hello, World!' + return hash == ref_hash +end + +-- Pipe +------------------------------------------------------------------------ +function file_exists (filename) + local fh = io.open(filename, 'r') + return fh ~= nil and (fh:close() or true) +end + +function warn (...) io.stderr:write(...) end + +function test_pipe () + if not file_exists('/bin/sed') then + warn 'Did not find /bin/sed, skipping test' + return true + end + local pipe_result = utils.pipe('/bin/sed', {'-e', 's/a/b/'}, 'abc') + return pipe_result == 'bbc' +end + +function test_failing_pipe () + if not file_exists('/bin/false') then + warn 'Did not find /bin/false, skipping test' + return true + end + local res, err = pcall(utils.pipe, '/bin/false', {}, 'abc') + return not res and + err.command == '/bin/false' and + err.error_code == 1 and + err.output == '' +end + +-- Read +------------------------------------------------------------------------ +function test_read () + local valid_markdown = '*Hello*, World!\n' + local res = pandoc.read(valid_markdown).blocks[1].content + return res[1].t == 'Emph' and res[3].t == 'Space' and res[4].t == 'Str' +end + +function test_failing_read () + local res, err = pcall(pandoc.read, 'foo', 'nosuchreader') + return not res and err:match 'Unknown reader: nosuchreader' +end + + +-- Return result +------------------------------------------------------------------------ +function run(fn) + return fn() and "OK" or "FAIL" +end + +function Para (el) + return { + pandoc.Plain{pandoc.Str("sha1: " .. run(test_sha1))}, + pandoc.Plain{pandoc.Str("pipe: " .. run(test_pipe))}, + pandoc.Plain{pandoc.Str("failing pipe: " .. run(test_failing_pipe))}, + pandoc.Plain{pandoc.Str("read: " .. run(test_read))}, + pandoc.Plain{pandoc.Str("failing read: " .. run(test_failing_read))}, + } +end diff --git a/test/tables.jats b/test/tables.jats index b213a83bb..46af61635 100644 --- a/test/tables.jats +++ b/test/tables.jats @@ -15,92 +15,60 @@ <thead> <tr> <th> - <p> - Right - </p> + Right </th> <th> - <p> - Left - </p> + Left </th> <th> - <p> - Center - </p> + Center </th> <th> - <p> - Default - </p> + Default </th> </tr> </thead> <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -117,92 +85,60 @@ <thead> <tr> <th> - <p> - Right - </p> + Right </th> <th> - <p> - Left - </p> + Left </th> <th> - <p> - Center - </p> + Center </th> <th> - <p> - Default - </p> + Default </th> </tr> </thead> <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -224,92 +160,60 @@ <thead> <tr> <th> - <p> - Right - </p> + Right </th> <th> - <p> - Left - </p> + Left </th> <th> - <p> - Center - </p> + Center </th> <th> - <p> - Default - </p> + Default </th> </tr> </thead> <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -332,70 +236,46 @@ <thead> <tr> <th> - <p> - Centered Header - </p> + Centered Header </th> <th> - <p> - Left Aligned - </p> + Left Aligned </th> <th> - <p> - Right Aligned - </p> + Right Aligned </th> <th> - <p> - Default aligned - </p> + Default aligned </th> </tr> </thead> <tbody> <tr> <td> - <p> - First - </p> + First </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 12.0 - </p> + 12.0 </td> <td> - <p> - Example of a row that spans multiple lines. - </p> + Example of a row that spans multiple lines. </td> </tr> <tr> <td> - <p> - Second - </p> + Second </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 5.0 - </p> + 5.0 </td> <td> - <p> - Here’s another one. Note the blank line between rows. - </p> + Here’s another one. Note the blank line between rows. </td> </tr> </tbody> @@ -412,70 +292,46 @@ <thead> <tr> <th> - <p> - Centered Header - </p> + Centered Header </th> <th> - <p> - Left Aligned - </p> + Left Aligned </th> <th> - <p> - Right Aligned - </p> + Right Aligned </th> <th> - <p> - Default aligned - </p> + Default aligned </th> </tr> </thead> <tbody> <tr> <td> - <p> - First - </p> + First </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 12.0 - </p> + 12.0 </td> <td> - <p> - Example of a row that spans multiple lines. - </p> + Example of a row that spans multiple lines. </td> </tr> <tr> <td> - <p> - Second - </p> + Second </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 5.0 - </p> + 5.0 </td> <td> - <p> - Here’s another one. Note the blank line between rows. - </p> + Here’s another one. Note the blank line between rows. </td> </tr> </tbody> @@ -491,68 +347,44 @@ <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -568,46 +400,30 @@ <tbody> <tr> <td> - <p> - First - </p> + First </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 12.0 - </p> + 12.0 </td> <td> - <p> - Example of a row that spans multiple lines. - </p> + Example of a row that spans multiple lines. </td> </tr> <tr> <td> - <p> - Second - </p> + Second </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 5.0 - </p> + 5.0 </td> <td> - <p> - Here’s another one. Note the blank line between rows. - </p> + Here’s another one. Note the blank line between rows. </td> </tr> </tbody> |