diff options
| author | Albert Krewinkel <[email protected]> | 2022-09-29 17:24:31 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-09-30 08:33:40 -0700 |
| commit | 5be9052f5fb7283372b3d5497bef499718a34992 (patch) | |
| tree | 80e5805786ef7ab08f363135861e1aa9c8868f6f /test | |
| parent | 79980eee4a1854921d7fb8b14848894b53cc21a7 (diff) | |
[API Change] Extract Lua code into new package pandoc-lua-engine
The flag 'lua53` must now be used with that package if pandoc is to be
compiled against Lua 5.3.
Diffstat (limited to 'test')
37 files changed, 1 insertions, 2704 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs deleted file mode 100644 index 6f544ccd4..000000000 --- a/test/Tests/Lua.hs +++ /dev/null @@ -1,246 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{- | - Module : Tests.Lua - Copyright : © 2017-2022 Albert Krewinkel - License : GNU GPL, version 2 or above - - Maintainer : Albert Krewinkel <[email protected]> - Stability : alpha - Portability : portable - -Unit and integration tests for pandoc's Lua subsystem. --} -module Tests.Lua ( runLuaTest, tests ) where - -import HsLua as Lua hiding (Operation (Div), error) -import System.FilePath ((</>)) -import Test.Tasty (TestTree, testGroup) -import Test.Tasty.HUnit ((@=?), Assertion, HasCallStack, assertEqual, testCase) -import Text.Pandoc.Arbitrary () -import Text.Pandoc.Builder (bulletList, definitionList, displayMath, divWith, - doc, doubleQuoted, emph, header, lineBlock, - linebreak, math, orderedList, para, plain, rawBlock, - singleQuoted, space, str, strong, - HasMeta (setMeta)) -import Text.Pandoc.Class (runIOorExplode, setUserDataDir) -import Text.Pandoc.Definition (Attr, Block (BlockQuote, Div, Para), Pandoc, - Inline (Emph, Str), pandocTypesVersion) -import Text.Pandoc.Error (PandocError (PandocLuaError)) -import Text.Pandoc.Lua (Global (..), applyFilter, runLua, setGlobals) -import Text.Pandoc.Options (def) -import Text.Pandoc.Shared (pandocVersionText) - -import qualified Control.Monad.Catch as Catch -import qualified Data.Text as T -import qualified Data.Text.Encoding as TE - -tests :: [TestTree] -tests = - [ testCase "macro expansion via filter" $ - assertFilterConversion "a '{{helloworld}}' string is expanded" - "strmacro.lua" - (doc . para $ str "{{helloworld}}") - (doc . para . emph $ str "Hello, World") - - , testCase "convert all plains to paras" $ - assertFilterConversion "plains become para" - "plain-to-para.lua" - (doc $ bulletList [plain (str "alfa"), plain (str "bravo")]) - (doc $ bulletList [para (str "alfa"), para (str "bravo")]) - - , testCase "convert display math to inline math" $ - assertFilterConversion "display math becomes inline math" - "math.lua" - (doc $ para (displayMath "5+5")) - (doc $ para (math "5+5")) - - , testCase "make hello world document" $ - assertFilterConversion "Document contains 'Hello, World!'" - "hello-world-doc.lua" - (doc . para $ str "Hey!" <> linebreak <> str "What's up?") - (doc . para $ str "Hello," <> space <> str "World!") - - , testCase "implicit doc filter" $ - assertFilterConversion "Document contains 'Hello, World!'" - "implicit-doc-filter.lua" - (doc . plain $ linebreak) - (doc . para $ str "Hello," <> space <> str "World!") - - , testCase "parse raw markdown blocks" $ - assertFilterConversion "raw markdown block is converted" - "markdown-reader.lua" - (doc $ rawBlock "markdown" "*charly* **delta**") - (doc . para $ emph "charly" <> space <> strong "delta") - - , testCase "allow shorthand functions for quote types" $ - assertFilterConversion "single quoted becomes double quoted string" - "single-to-double-quoted.lua" - (doc . para . singleQuoted $ str "simple") - (doc . para . doubleQuoted $ str "simple") - - , testCase "Count inlines via metatable catch-all" $ - assertFilterConversion "filtering with metatable catch-all failed" - "metatable-catch-all.lua" - (doc . para $ "four words, three spaces") - (doc . para $ str "7") - - , testCase "Count blocks via Block-specific catch-all" $ - assertFilterConversion "filtering with Block catch-all failed" - "block-count.lua" - (doc $ para "one" <> para "two") - (doc $ para "2") - - , testCase "Smart constructors" $ - assertFilterConversion "smart constructors returned a wrong result" - "smart-constructors.lua" - (doc $ para "") - (doc $ mconcat - [ bulletList [para "Hello", para "World"] - , definitionList [("foo", [para "placeholder"])] - , lineBlock ["Moin", "Welt"] - , orderedList [plain "one", plain "two"] - ]) - - , testCase "Convert header upper case" $ - assertFilterConversion "converting header to upper case failed" - "uppercase-header.lua" - (doc $ header 1 "les états-unis" <> para "text") - (doc $ header 1 "LES ÉTATS-UNIS" <> para "text") - - , testCase "Attribute lists are convenient to use" $ - let kv_before = [("one", "1"), ("two", "2"), ("three", "3")] - kv_after = [("one", "eins"), ("three", "3"), ("five", "5")] - in assertFilterConversion "Attr doesn't behave as expected" - "attr-test.lua" - (doc $ divWith ("", [], kv_before) (para "nil")) - (doc $ divWith ("", [], kv_after) (para "nil")) - - , testCase "Filter list of inlines" $ - assertFilterConversion "List of inlines" - "inlines-filter.lua" - (doc $ para ("Hello," <> linebreak <> "World! Wassup?")) - (doc $ para "Hello, World! Wassup?") - - , testCase "Filter list of blocks" $ - assertFilterConversion "List of blocks" - "blocks-filter.lua" - (doc $ para "one." <> para "two." <> para "three.") - (doc $ plain "3") - - , testCase "Filter Meta" $ - let setMetaBefore = setMeta "old" ("old" :: T.Text) - . setMeta "bool" False - setMetaAfter = setMeta "new" ("new" :: T.Text) - . setMeta "bool" True - in assertFilterConversion "Meta filtering" - "meta.lua" - (setMetaBefore . doc $ mempty) - (setMetaAfter . doc $ mempty) - - , testCase "Script filename is set" $ - assertFilterConversion "unexpected script name" - "script-name.lua" - (doc $ para "ignored") - (doc $ para (str $ T.pack $ "lua" </> "script-name.lua")) - - , testCase "Pandoc version is set" . runLuaTest $ do - Lua.getglobal "PANDOC_VERSION" - Lua.liftIO . - assertEqual "pandoc version is wrong" (TE.encodeUtf8 pandocVersionText) - =<< Lua.tostring' Lua.top - - , testCase "Pandoc types version is set" . runLuaTest $ do - Lua.getglobal "PANDOC_API_VERSION" - Lua.liftIO . assertEqual "pandoc-types version is wrong" pandocTypesVersion - =<< Lua.peek Lua.top - - , testCase "require file" $ - assertFilterConversion "requiring file failed" - "require-file.lua" - (doc $ para "ignored") - (doc $ para (str . T.pack $ "lua" </> "require-file.lua")) - - , testCase "Allow singleton inline in constructors" . runLuaTest $ do - Lua.liftIO . assertEqual "Not the expected Emph" - (Emph [Str "test"]) =<< do - Lua.OK <- Lua.dostring "return pandoc.Emph" - Lua.push @Inline (Str "test") - Lua.call 1 1 - Lua.peek @Inline top - Lua.liftIO . assertEqual "Unexpected element" - (Para [Str "test"]) =<< do - Lua.getglobal' "pandoc.Para" - Lua.pushString "test" - Lua.call 1 1 - Lua.peek @Block top - Lua.liftIO . assertEqual "Unexptected element" - (BlockQuote [Para [Str "foo"]]) =<< ( - do - Lua.getglobal' "pandoc.BlockQuote" - Lua.push (Para [Str "foo"]) - _ <- Lua.call 1 1 - Lua.peek @Block Lua.top - ) - - , testCase "Elements with Attr have `attr` accessor" . runLuaTest $ do - Lua.push (Div ("hi", ["moin"], []) - [Para [Str "ignored"]]) - Lua.getfield Lua.top "attr" - Lua.liftIO . assertEqual "no accessor" (("hi", ["moin"], []) :: Attr) - =<< Lua.peek @Attr Lua.top - - , testCase "module `pandoc.system` is present" . runLuaTest $ do - Lua.getglobal' "pandoc.system" - ty <- Lua.ltype Lua.top - Lua.liftIO $ assertEqual "module should be a table" Lua.TypeTable ty - - , testGroup "global modules" - [ testCase "module 'lpeg' is loaded into a global" . runLuaTest $ do - s <- Lua.dostring "assert(type(lpeg)=='table')" - Lua.liftIO $ Lua.OK @=? s - - , testCase "module 're' is loaded into a global" . runLuaTest $ do - s <- Lua.dostring "assert(type(re)=='table')" - Lua.liftIO $ Lua.OK @=? s - - , testCase "module 'lpeg' is available via `require`" . runLuaTest $ do - s <- Lua.dostring - "package.path = ''; package.cpath = ''; require 'lpeg'" - Lua.liftIO $ Lua.OK @=? s - - , testCase "module 're' is available via `require`" . runLuaTest $ do - s <- Lua.dostring - "package.path = ''; package.cpath = ''; require 're'" - Lua.liftIO $ Lua.OK @=? s - ] - - , testCase "informative error messages" . runLuaTest $ do - Lua.pushboolean True - -- Lua.newtable - eitherPandoc <- Catch.try (peek @Pandoc Lua.top) - case eitherPandoc of - Left (PandocLuaError msg) -> do - let expectedMsg = "Pandoc expected, got boolean\n" - <> "\twhile retrieving Pandoc" - Lua.liftIO $ assertEqual "unexpected error message" expectedMsg msg - Left e -> error ("Expected a Lua error, but got " <> show e) - Right _ -> error "Getting a Pandoc element from a bool should fail." - ] - -assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion -assertFilterConversion msg filterPath docIn expectedDoc = do - actualDoc <- runIOorExplode $ do - setUserDataDir (Just "../data") - applyFilter def ["HTML"] ("lua" </> filterPath) docIn - assertEqual msg expectedDoc actualDoc - -runLuaTest :: HasCallStack => Lua.LuaE PandocError a -> IO a -runLuaTest op = runIOorExplode $ do - res <- runLua $ do - setGlobals [ PANDOC_WRITER_OPTIONS def ] - op - case res of - Left e -> error (show e) - Right x -> return x diff --git a/test/Tests/Lua/Module.hs b/test/Tests/Lua/Module.hs deleted file mode 100644 index fd3fc8998..000000000 --- a/test/Tests/Lua/Module.hs +++ /dev/null @@ -1,41 +0,0 @@ -{- | -Module : Tests.Lua.Module -Copyright : © 2019-2022 Albert Krewinkel -License : GNU GPL, version 2 or above - -Maintainer : Albert Krewinkel <[email protected]> -Stability : alpha -Portability : portable - -Lua module tests --} -module Tests.Lua.Module (tests) where - -import System.FilePath ((</>)) -import Test.Tasty (TestName, TestTree) -import Test.Tasty.Lua (testLuaFile) - -import Tests.Lua (runLuaTest) - -tests :: [TestTree] -tests = - [ testPandocLua "pandoc" - ("lua" </> "module" </> "pandoc.lua") - , testPandocLua "pandoc.List" - ("lua" </> "module" </> "pandoc-list.lua") - , testPandocLua "pandoc.mediabag" - ("lua" </> "module" </> "pandoc-mediabag.lua") - , testPandocLua "pandoc.path" - ("lua" </> "module" </> "pandoc-path.lua") - , testPandocLua "pandoc.template" - ("lua" </> "module" </> "pandoc-template.lua") - , testPandocLua "pandoc.types" - ("lua" </> "module" </> "pandoc-types.lua") - , testPandocLua "pandoc.utils" - ("lua" </> "module" </> "pandoc-utils.lua") - , testPandocLua "globals" - ("lua" </> "module" </> "globals.lua") - ] - -testPandocLua :: TestName -> FilePath -> TestTree -testPandocLua = testLuaFile runLuaTest diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index a64469e6d..0d20c151a 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -194,12 +194,6 @@ tests pandocPath = [ test' "reader" ["-r", "creole", "-w", "native", "-s"] "creole-reader.txt" "creole-reader.native" ] - , testGroup "custom writer" - [ test' "basic" ["-f", "native", "-t", "../data/sample.lua"] - "testsuite.native" "writer.custom" - , 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" diff --git a/test/command/lua-pandoc-state.lua b/test/command/lua-pandoc-state.lua deleted file mode 100644 index 5282a4c29..000000000 --- a/test/command/lua-pandoc-state.lua +++ /dev/null @@ -1,11 +0,0 @@ -function report (what, value) - print(string.format('%16s: %s', what, value)) -end -report('# input files', #PANDOC_STATE.input_files) -report('output file', PANDOC_STATE.output_file) -report('# request header', #PANDOC_STATE.request_headers) -report('resource path', table.concat(PANDOC_STATE.resource_path, ', ')) -report('source URL', PANDOC_STATE.source_url) -report('user data dir', PANDOC_STATE.user_data_dir and 'defined' or 'unset') -report('trace', PANDOC_STATE.trace) -report('verbosity', PANDOC_STATE.verbosity) diff --git a/test/command/lua-pandoc-state.md b/test/command/lua-pandoc-state.md deleted file mode 100644 index e56d75af5..000000000 --- a/test/command/lua-pandoc-state.md +++ /dev/null @@ -1,14 +0,0 @@ -``` -% pandoc --lua-filter=command/lua-pandoc-state.lua --data-dir=foo -Hello -^D - # input files: 1 - output file: nil -# request header: 0 - resource path: . - source URL: nil - user data dir: defined - trace: false - verbosity: WARNING -<p>Hello</p> -``` diff --git a/test/lua/attr-test.lua b/test/lua/attr-test.lua deleted file mode 100644 index 68dc0012d..000000000 --- a/test/lua/attr-test.lua +++ /dev/null @@ -1,6 +0,0 @@ -function Div (div) - div.attributes.five = ("%d"):format(div.attributes.two + div.attributes.three) - div.attributes.two = nil - div.attributes.one = "eins" - return div -end diff --git a/test/lua/block-count.lua b/test/lua/block-count.lua deleted file mode 100644 index 508b05ea8..000000000 --- a/test/lua/block-count.lua +++ /dev/null @@ -1,11 +0,0 @@ -local num_blocks = 0 - -function Block(el) - num_blocks = num_blocks + 1 -end - -function Pandoc(blocks, meta) - return pandoc.Pandoc { - pandoc.Para{pandoc.Str(num_blocks)} - } -end diff --git a/test/lua/blocks-filter.lua b/test/lua/blocks-filter.lua deleted file mode 100644 index 4e944e922..000000000 --- a/test/lua/blocks-filter.lua +++ /dev/null @@ -1,8 +0,0 @@ -function Blocks (blks) - -- verify that this looks like a `pandoc.List` - if not blks.find or not blks.map or not blks.filter then - error("table doesn't seem to be an instance of pandoc.List") - end - -- return plain block containing the number of elements in the list - return {pandoc.Plain {pandoc.Str(tostring(#blks))}} -end diff --git a/test/lua/hello-world-doc.lua b/test/lua/hello-world-doc.lua deleted file mode 100644 index 62236584e..000000000 --- a/test/lua/hello-world-doc.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - Pandoc = function(doc) - local meta = {} - local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" } - local blocks = { pandoc.Para(hello) } - return pandoc.Pandoc(blocks, meta) - end - } -} diff --git a/test/lua/implicit-doc-filter.lua b/test/lua/implicit-doc-filter.lua deleted file mode 100644 index f053dc1b2..000000000 --- a/test/lua/implicit-doc-filter.lua +++ /dev/null @@ -1,6 +0,0 @@ -function Pandoc (doc) - local meta = {} - local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" } - local blocks = { pandoc.Para(hello) } - return pandoc.Pandoc(blocks, meta) -end diff --git a/test/lua/inlines-filter.lua b/test/lua/inlines-filter.lua deleted file mode 100644 index 69608bd77..000000000 --- a/test/lua/inlines-filter.lua +++ /dev/null @@ -1,19 +0,0 @@ -function isWorldAfterSpace (fst, snd) - return fst and fst.t == 'LineBreak' - and snd and snd.t == 'Str' and snd.text == 'World!' -end - -function Inlines (inlns) - -- verify that this looks like a `pandoc.List` - if not inlns.find or not inlns.map or not inlns.filter then - error("table doesn't seem to be an instance of pandoc.List") - end - - -- Remove spaces before string "World" - for i = #inlns-1,1,-1 do - if isWorldAfterSpace(inlns[i], inlns[i+1]) then - inlns[i] = pandoc.Space() - end - end - return inlns -end diff --git a/test/lua/markdown-reader.lua b/test/lua/markdown-reader.lua deleted file mode 100644 index 1530a15a2..000000000 --- a/test/lua/markdown-reader.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - { - RawBlock = function (elem) - if elem.format == "markdown" then - local pd = pandoc.read(elem.text, "markdown") - return pd.blocks[1] - else - return elem - end - end, - } -} diff --git a/test/lua/math.lua b/test/lua/math.lua deleted file mode 100644 index 34307dd9e..000000000 --- a/test/lua/math.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - Math = function (elem) - if elem.mathtype == "DisplayMath" then - elem.mathtype = "InlineMath" - end - return elem - end, - } -} diff --git a/test/lua/meta.lua b/test/lua/meta.lua deleted file mode 100644 index 5e2946203..000000000 --- a/test/lua/meta.lua +++ /dev/null @@ -1,6 +0,0 @@ -function Meta (meta) - meta.old = nil - meta.new = "new" - meta.bool = (meta.bool == false) - return meta -end diff --git a/test/lua/metatable-catch-all.lua b/test/lua/metatable-catch-all.lua deleted file mode 100644 index 05df16bbf..000000000 --- a/test/lua/metatable-catch-all.lua +++ /dev/null @@ -1,20 +0,0 @@ -local num_inlines = 0 - -function catch_all(el) - if el.tag and pandoc.Inline.constructor[el.tag] then - num_inlines = num_inlines + 1 - end -end - -function Pandoc(blocks, meta) - return pandoc.Pandoc { - pandoc.Para{pandoc.Str(num_inlines)} - } -end - -return { - setmetatable( - {Pandoc = Pandoc}, - {__index = function(_) return catch_all end} - ) -} diff --git a/test/lua/module/globals.lua b/test/lua/module/globals.lua deleted file mode 100644 index 85b287cf2..000000000 --- a/test/lua/module/globals.lua +++ /dev/null @@ -1,108 +0,0 @@ -local tasty = require 'tasty' - -local test = tasty.test_case -local group = tasty.test_group -local assert = tasty.assert - --- These tests exist mainly to catch changes to the JSON representation of --- WriterOptions and its components. UPDATE THE DOCS if anything changes. -return { - group 'PANDOC_WRITER_OPTIONS' { - test('cite_method', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.cite_method), 'string') - end), - test('columns', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.columns), 'number') - end), - test('dpi', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.dpi), 'number') - end), - test('email_obfuscation', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.email_obfuscation), 'string') - end), - test('epub_chapter_level', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_chapter_level), 'number') - end), - test('epub_fonts', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_fonts), 'table') - end), - test('epub_metadata', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_metadata), 'nil') - end), - test('epub_subdirectory', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.epub_subdirectory), 'string') - end), - test('extensions', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.extensions), 'table') - for _, v in ipairs(PANDOC_WRITER_OPTIONS.extensions) do - assert.are_equal(type(v), 'string') - end - end), - test('highlight_style', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.highlight_style), 'table') - end), - test('html_math_method', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.html_math_method), 'string') - end), - test('html_q_tags', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.html_q_tags), 'boolean') - end), - test('identifier_prefix', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.identifier_prefix), 'string') - end), - test('incremental', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.incremental), 'boolean') - end), - test('listings', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.listings), 'boolean') - end), - test('number_offset', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.number_offset), 'table') - for _, v in ipairs(PANDOC_WRITER_OPTIONS.number_offset) do - assert.are_equal(type(v), 'number') - end - end), - test('number_sections', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.number_sections), 'boolean') - end), - test('prefer_ascii', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.prefer_ascii), 'boolean') - end), - test('reference_doc', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.reference_doc), 'nil') - end), - test('reference_links', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.reference_links), 'boolean') - end), - test('reference_location', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.reference_location), 'string') - end), - test('section_divs', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.section_divs), 'boolean') - end), - test('setext_headers', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.setext_headers), 'boolean') - end), - test('slide_level', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.slide_level), 'nil') - end), - test('tab_stop', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.tab_stop), 'number') - end), - test('table_of_contents', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.table_of_contents), 'boolean') - end), - test('toc_depth', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.toc_depth), 'number') - end), - test('top_level_division', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.top_level_division), 'string') - end), - test('variables', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.variables), 'table') - end), - test('wrap_text', function () - assert.are_equal(type(PANDOC_WRITER_OPTIONS.wrap_text), 'string') - end), - } -} diff --git a/test/lua/module/pandoc-list.lua b/test/lua/module/pandoc-list.lua deleted file mode 100644 index 27790ce96..000000000 --- a/test/lua/module/pandoc-list.lua +++ /dev/null @@ -1,160 +0,0 @@ -local tasty = require 'tasty' -local List = require 'pandoc.List' - -local assert = tasty.assert -local test = tasty.test_case -local group = tasty.test_group - -return { - group 'List as function' { - test('equivalent to List:new', function (x) - local new = List:new {'ramen'} - local list = List {'ramen'} - assert.are_same(new, list) - assert.are_equal(getmetatable(new), getmetatable(list)) - end) - }, - - group 'clone' { - test('changing the clone does not affect original', function () - local orig = List:new {23, 42} - local copy = orig:clone() - copy[1] = 5 - assert.are_same({23, 42}, orig) - assert.are_same({5, 42}, copy) - end), - test('result is a list', function () - local orig = List:new {23, 42} - assert.are_equal(List, getmetatable(orig:clone())) - end), - }, - - group 'extend' { - test('extends list with other list', function () - local primes = List:new {2, 3, 5, 7} - primes:extend {11, 13, 17} - assert.are_same({2, 3, 5, 7, 11, 13, 17}, primes) - end) - }, - - group 'filter' { - test('keep elements for which property is truthy', function () - local is_small_prime = function (x) - return List.includes({2, 3, 5, 7}, x) - end - local numbers = List:new {4, 7, 2, 9, 5, 11} - assert.are_same({7, 2, 5}, numbers:filter(is_small_prime)) - end), - }, - - group 'find' { - test('returns element and index if found', function () - local list = List:new {5, 23, 71} - local elem, idx = list:find(71) - assert.are_same(71, elem) - assert.are_same(3, idx) - end), - test('respects start index', function () - local list = List:new {19, 23, 29, 71} - assert.are_equal(23, list:find(23, 1)) - assert.are_equal(23, list:find(23, 2)) - assert.is_nil(list:find(23, 3)) - end), - test('returns nil if element not found', function () - assert.is_nil((List:new {18, 20, 22, 0, 24}):find('0')) - end), - }, - - group 'find_if' { - test('returns element and index if found', function () - local perm_prime = List:new {2, 3, 5, 7, 11, 13, 17, 31, 37, 71} - local elem, idx = perm_prime:find_if(function (x) return x >= 10 end) - assert.are_same(11, elem) - assert.are_same(5, idx) - end), - test('returns nil if element not found', function () - local is_null = function (n) return List.includes({23,35,46,59}, n) end - assert.is_nil((List:new {18, 20, 22, 24, 27}):find_if(is_null)) - end), - }, - - group 'includes' { - test('finds elements in list', function () - local lst = List:new {'one', 'two', 'three'} - assert.is_truthy(lst:includes('one')) - assert.is_truthy(lst:includes('two')) - assert.is_truthy(lst:includes('three')) - assert.is_falsy(lst:includes('four')) - end) - }, - - group 'insert' { - test('insert value at end of list.', function () - local count_norsk = List {'en', 'to', 'tre'} - count_norsk:insert('fire') - assert.are_same({'en', 'to', 'tre', 'fire'}, count_norsk) - end), - test('insert value in the middle of list.', function () - local count_norsk = List {'fem', 'syv'} - count_norsk:insert(2, 'seks') - assert.are_same({'fem', 'seks', 'syv'}, count_norsk) - end) - }, - - group 'map' { - test('applies function to elements', function () - local primes = List:new {2, 3, 5, 7} - local squares = primes:map(function (x) return x^2 end) - assert.are_same({4, 9, 25, 49}, squares) - end), - test('leaves original list unchanged', function () - local primes = List:new {2, 3, 5, 7} - local squares = primes:map(function (x) return x^2 end) - assert.are_same({2, 3, 5, 7}, primes) - end) - }, - - group 'new' { - test('make table usable as list', function () - local test = List:new{1, 1, 2, 3, 5} - assert.are_same( - {1, 1, 4, 9, 25}, - test:map(function (x) return x^2 end) - ) - end), - test('return empty list if no argument is given', function () - assert.are_same({}, List:new()) - end), - test('metatable of result is pandoc.List', function () - local test = List:new{5} - assert.are_equal(List, getmetatable(test)) - end) - }, - - group 'remove' { - test('remove value at end of list.', function () - local understand = List {'jeg', 'forstår', 'ikke'} - local norsk_not = understand:remove() - assert.are_same({'jeg', 'forstår'}, understand) - assert.are_equal('ikke', norsk_not) - end), - test('remove value at beginning of list.', function () - local count_norsk = List {'en', 'to', 'tre'} - count_norsk:remove(1) - assert.are_same({'to', 'tre'}, count_norsk) - end) - }, - - group 'sort' { - test('sort numeric list', function () - local numbers = List {71, 5, -1, 42, 23, 0, 1} - numbers:sort() - assert.are_same({-1, 0, 1, 5, 23, 42, 71}, numbers) - end), - test('reverse-sort numeric', function () - local numbers = List {71, 5, -1, 42, 23, 0, 1} - numbers:sort(function (x, y) return x > y end) - assert.are_same({71, 42, 23, 5, 1, 0, -1}, numbers) - end) - }, -} diff --git a/test/lua/module/pandoc-mediabag.lua b/test/lua/module/pandoc-mediabag.lua deleted file mode 100644 index 5ff65ee44..000000000 --- a/test/lua/module/pandoc-mediabag.lua +++ /dev/null @@ -1,72 +0,0 @@ -local tasty = require 'tasty' - -local test = tasty.test_case -local group = tasty.test_group -local assert = tasty.assert - -local mediabag = require 'pandoc.mediabag' - -return { - group 'insert' { - test('insert adds an item to the mediabag', function () - local fp = "media/hello.txt" - local mt = "text/plain" - local contents = "Hello, World!" - assert.are_same(mediabag.list(), {}) - mediabag.insert(fp, mt, contents) - assert.are_same( - mediabag.list(), - {{['path'] = fp, ['type'] = mt, ['length'] = 13}} - ) - mediabag.empty() -- clean up - end), - test('is idempotent', function () - local fp = "media/hello.txt" - local mt = "text/plain" - local contents = "Hello, World!" - mediabag.insert(fp, mt, contents) - mediabag.insert(fp, mt, contents) - assert.are_same( - mediabag.list(), - {{['path'] = fp, ['type'] = mt, ['length'] = 13}} - ) - mediabag.empty() -- clean up - end), - }, - - group 'delete' { - test('removes an item', function () - assert.are_same(mediabag.list(), {}) - mediabag.insert('test.html', 'text/html', '<aside>Who cares?</aside>') - mediabag.insert('test.css', 'text/plain', 'aside { color: red; }') - assert.are_equal(#mediabag.list(), 2) - mediabag.delete('test.html') - assert.are_same( - mediabag.list(), - {{['path'] = 'test.css', ['type'] = 'text/plain', ['length'] = 21}} - ) - mediabag.empty() -- clean up - end), - }, - - group 'items' { - test('iterates over all items', function () - local input_items = { - ['test.html'] = {'text/html', '<aside>Really?</aside>'}, - ['test.css'] = {'text/plain', 'aside { color: red; }'}, - ['test.js'] = {'application/javascript', 'alert("HI MOM!")'} - } - -- fill mediabag - for name, v in pairs(input_items) do - mediabag.insert(name, v[1], v[2]) - end - - local seen_items = {} - for fp, mt, c in mediabag.items() do - seen_items[fp] = {mt, c} - end - assert.are_same(seen_items, input_items) - mediabag.empty() -- clean up - end) - } -} diff --git a/test/lua/module/pandoc-path.lua b/test/lua/module/pandoc-path.lua deleted file mode 100644 index 81c11e7b7..000000000 --- a/test/lua/module/pandoc-path.lua +++ /dev/null @@ -1,44 +0,0 @@ -local tasty = require 'tasty' -local path = require 'pandoc.path' - -local assert = tasty.assert -local test = tasty.test_case -local group = tasty.test_group - -return { - group 'path separator' { - test('is string', function () - assert.are_same(type(path.separator), 'string') - end), - test('is slash or backslash', function () - assert.is_truthy(path.separator:match '^[/\\]$') - end), - }, - group 'search path separator' { - test('is string', function () - assert.are_same(type(path.search_path_separator), 'string') - end), - test('is colon or semicolon', function () - assert.is_truthy(path.search_path_separator:match '^[:;]$') - end) - }, - group 'module' { - test('check function existence', function () - local functions = { - 'directory', - 'filename', - 'is_absolute', - 'is_relative', - 'join', - 'make_relative', - 'normalize', - 'split', - 'split_extension', - 'split_search_path', - } - for _, f in ipairs(functions) do - assert.are_equal(type(path[f]), 'function') - end - end) - } -} diff --git a/test/lua/module/pandoc-template.lua b/test/lua/module/pandoc-template.lua deleted file mode 100644 index c288b2016..000000000 --- a/test/lua/module/pandoc-template.lua +++ /dev/null @@ -1,65 +0,0 @@ -local tasty = require 'tasty' -local template = require 'pandoc.template' - -local assert = tasty.assert -local test = tasty.test_case -local group = tasty.test_group - -return { - test('is table', function () - assert.are_equal(type(template), 'table') - end), - group 'default' { - test('is function', function () - assert.are_equal(type(template.default), 'function') - end), - test('returns a string for known format', function () - assert.are_equal( - pandoc.utils.type(template.default 'json'), - 'string' - ) - assert.are_equal( - pandoc.utils.type(template.default 'markdown'), - 'string' - ) - end), - test('fails on unknown format', function () - local success, msg = pcall(function () - return pandoc.utils.type(template.default 'nosuchformat') - end) - assert.is_falsy(success) - end), - }, - group 'compile' { - test('is function', function () - assert.are_equal(type(template.compile), 'function') - end), - test('returns a Template', function () - assert.are_equal( - pandoc.utils.type(template.compile('$title$')), - 'pandoc Template' - ) - end), - test('returns a Template', function () - local templ_path = pandoc.path.join{'lua', 'module', 'default.test'} - assert.are_equal( - pandoc.utils.type(template.compile('${ partial() }', templ_path)), - 'pandoc Template' - ) - end), - test('fails if template has non-existing partial', function () - assert.error_matches( - function () return template.compile('${ nosuchpartial() }') end, - 'PandocCouldNotFindDataFileError' - ) - end), - test('works with default template that uses partials', function () - local jats_template = template.default 'jats' - assert.are_equal(type(jats_template), 'string') - assert.are_equal( - pandoc.utils.type(template.compile(jats_template)), - 'pandoc Template' - ) - end), - }, -} diff --git a/test/lua/module/pandoc-types.lua b/test/lua/module/pandoc-types.lua deleted file mode 100644 index d9c9f82ac..000000000 --- a/test/lua/module/pandoc-types.lua +++ /dev/null @@ -1,86 +0,0 @@ -local tasty = require 'tasty' -local types = require 'pandoc.types' -local Version = types.Version - -local assert = tasty.assert -local test = tasty.test_case -local group = tasty.test_group - -return { - group 'Version' { - - group 'constructor' { - test('has type `userdata`', function () - assert.are_same(type(Version {2}), 'userdata') - end), - test('accepts list of integers', function () - assert.are_same(type(Version {2, 7, 3}), 'userdata') - end), - test('accepts a single integer', function () - assert.are_same(Version(5), Version {5}) - end), - test('accepts version as string', function () - assert.are_same( - Version '4.45.1', - Version {4, 45, 1} - ) - end), - test('non-version string is rejected', function () - local success, msg = pcall(function () Version '11friends' end) - assert.is_falsy(success) - assert.is_truthy(tostring(msg):match('11friends')) - end) - }, - - group 'comparison' { - test('smaller (equal) than', function () - assert.is_truthy(Version {2, 58, 3} < Version {2, 58, 4}) - assert.is_falsy(Version {2, 60, 1} < Version {2, 59, 2}) - assert.is_truthy(Version {0, 14, 3} < Version {0, 14, 3, 1}) - assert.is_truthy(Version {3, 58, 3} <= Version {4}) - assert.is_truthy(Version {0, 14, 3} <= Version {0, 14, 3, 1}) - end), - test('larger (equal) than', function () - assert.is_truthy(Version{2,58,3} > Version {2, 57, 4}) - assert.is_truthy(Version{2,58,3} > Version {2, 58, 2}) - assert.is_truthy(Version {0, 8} >= Version {0, 8}) - assert.is_falsy(Version {0, 8} >= Version {0, 8, 2}) - end), - test('equality', function () - assert.is_truthy(Version '8.8', Version {8, 8}) - end), - test('second argument can be a version string', function () - assert.is_truthy(Version '8' < '9.1') - assert.is_falsy(Version '8.8' < '8.7') - end), - }, - - group 'conversion to string' { - test('converting from and to string is a noop', function () - local version_string = '1.19.4' - assert.are_equal(tostring(Version(version_string)), version_string) - end) - }, - - group 'convenience functions' { - test('throws error if version is too old', function () - local actual = Version {2, 8} - local expected = Version {2, 9} - assert.error_matches( - function () actual:must_be_at_least(expected) end, - 'expected version 2.9 or newer, got 2.8' - ) - end), - test('does nothing if expected version is older than actual', function () - local actual = Version '2.9' - local expected = Version '2.8' - actual:must_be_at_least(expected) - end), - test('does nothing if expected version equals to actual', function () - local actual = Version '2.8' - local expected = Version '2.8' - actual:must_be_at_least(expected) - end) - } - } -} diff --git a/test/lua/module/pandoc-utils.lua b/test/lua/module/pandoc-utils.lua deleted file mode 100644 index 4cf2c84a7..000000000 --- a/test/lua/module/pandoc-utils.lua +++ /dev/null @@ -1,333 +0,0 @@ -local tasty = require 'tasty' -local utils = require 'pandoc.utils' - -local assert = tasty.assert -local test = tasty.test_case -local group = tasty.test_group - -return { - group 'blocks_to_inlines' { - test('default separator', function () - local blocks = { - pandoc.Para { pandoc.Str 'Paragraph1' }, - pandoc.Para { pandoc.Emph { pandoc.Str 'Paragraph2' } } - } - local expected = { - pandoc.Str 'Paragraph1', - pandoc.Space(), pandoc.Str '¶', pandoc.Space(), - pandoc.Emph { pandoc.Str 'Paragraph2' } - } - assert.are_same( - expected, - utils.blocks_to_inlines(blocks) - ) - end), - test('custom separator', function () - local blocks = { - pandoc.Para{ pandoc.Str 'Paragraph1' }, - pandoc.Para{ pandoc.Emph 'Paragraph2' } - } - local expected = { - pandoc.Str 'Paragraph1', - pandoc.LineBreak(), - pandoc.Emph { pandoc.Str 'Paragraph2' } - } - assert.are_same( - expected, - utils.blocks_to_inlines(blocks, { pandoc.LineBreak() }) - ) - end) - }, - - group 'equals' { - test('compares Pandoc elements', function () - assert.is_truthy( - utils.equals(pandoc.Pandoc{'foo'}, pandoc.Pandoc{'foo'}) - ) - end), - test('compares Block elements', function () - assert.is_truthy( - utils.equals(pandoc.Plain{'foo'}, pandoc.Plain{'foo'}) - ) - assert.is_falsy( - utils.equals(pandoc.Para{'foo'}, pandoc.Plain{'foo'}) - ) - end), - test('compares Inline elements', function () - assert.is_truthy( - utils.equals(pandoc.Emph{'foo'}, pandoc.Emph{'foo'}) - ) - assert.is_falsy( - utils.equals(pandoc.Emph{'foo'}, pandoc.Strong{'foo'}) - ) - end), - test('compares Inline with Block elements', function () - assert.is_falsy( - utils.equals(pandoc.Emph{'foo'}, pandoc.Plain{'foo'}) - ) - assert.is_falsy( - utils.equals(pandoc.Para{'foo'}, pandoc.Strong{'foo'}) - ) - end), - test('compares Pandoc with Block elements', function () - assert.is_falsy( - utils.equals(pandoc.Pandoc{'foo'}, pandoc.Plain{'foo'}) - ) - assert.is_falsy( - utils.equals(pandoc.Para{'foo'}, pandoc.Pandoc{'foo'}) - ) - end), - }, - - group 'make_sections' { - test('sanity check', function () - local blks = { - pandoc.Header(1, {pandoc.Str 'First'}), - pandoc.Header(2, {pandoc.Str 'Second'}), - pandoc.Header(2, {pandoc.Str 'Third'}), - } - local hblks = utils.make_sections(true, 1, blks) - assert.are_equal('Div', hblks[1].t) - assert.are_equal('Header', hblks[1].content[1].t) - assert.are_equal('1', hblks[1].content[1].attributes['number']) - end) - }, - - group 'normalize_date' { - test('09 Nov 1989', function () - assert.are_equal('1989-11-09', utils.normalize_date '09 Nov 1989') - end), - test('12/31/2017', function () - assert.are_equal('2017-12-31', utils.normalize_date '12/31/2017') - end), - }, - - group 'references' { - test('gets references from doc', function () - local ref = { - ['author'] = { - {given = 'Max', family = 'Mustermann'} - }, - ['container-title'] = pandoc.Inlines('JOSS'), - ['id'] = 'test', - ['issued'] = {['date-parts'] = {{2021}}}, - ['title'] = pandoc.Inlines{ - pandoc.Quoted('DoubleQuote', 'Interesting'), - pandoc.Space(), - 'work' - }, - ['type'] = 'article-journal', - } - local nocite = pandoc.Cite( - '@test', - {pandoc.Citation('test', 'NormalCitation')} - ) - local doc = pandoc.Pandoc({}, {nocite = nocite, references = {ref}}) - assert.are_same({ref}, pandoc.utils.references(doc)) - end) - }, - - group 'sha1' { - test('hashing', function () - local ref_hash = '0a0a9f2a6772942557ab5355d76af442f8f65e01' - assert.are_equal(ref_hash, utils.sha1 'Hello, World!') - end) - }, - - group 'stringify' { - test('Inline', function () - local inline = pandoc.Emph{ - pandoc.Str 'Cogito', - pandoc.Space(), - pandoc.Str 'ergo', - pandoc.Space(), - pandoc.Str 'sum.', - } - assert.are_equal('Cogito ergo sum.', utils.stringify(inline)) - end), - test('Block', function () - local block = pandoc.Para{ - pandoc.Str 'Make', - pandoc.Space(), - pandoc.Str 'it', - pandoc.Space(), - pandoc.Str 'so.', - } - assert.are_equal('Make it so.', utils.stringify(block)) - end), - test('boolean', function () - assert.are_equal('true', utils.stringify(true)) - assert.are_equal('false', utils.stringify(false)) - end), - test('number', function () - assert.are_equal('5', utils.stringify(5)) - assert.are_equal('23.23', utils.stringify(23.23)) - end), - test('Attr', function () - local attr = pandoc.Attr('foo', {'bar'}, {a = 'b'}) - assert.are_equal('', utils.stringify(attr)) - end), - test('List', function () - local list = pandoc.List{pandoc.Str 'a', pandoc.Blocks('b')} - assert.are_equal('ab', utils.stringify(list)) - end), - test('Blocks', function () - local blocks = pandoc.Blocks{pandoc.Para 'a', pandoc.Header(1, 'b')} - assert.are_equal('ab', utils.stringify(blocks)) - end), - test('Inlines', function () - local inlines = pandoc.Inlines{pandoc.Str 'a', pandoc.Subscript('b')} - assert.are_equal('ab', utils.stringify(inlines)) - end), - test('Meta', function () - local meta = pandoc.Meta{ - a = pandoc.Inlines 'funny and ', - b = 'good movie', - c = pandoc.List{pandoc.Inlines{pandoc.Str '!'}} - } - assert.are_equal('funny and good movie!', utils.stringify(meta)) - end), - }, - - group 'to_roman_numeral' { - test('convertes number', function () - assert.are_equal('MDCCCLXXXVIII', utils.to_roman_numeral(1888)) - end), - test('fails on non-convertible argument', function () - assert.is_falsy(pcall(utils.to_roman_numeral, 'not a number')) - end) - }, - - group 'type' { - test('nil', function () - assert.are_equal(utils.type(nil), 'nil') - end), - test('boolean', function () - assert.are_equal(utils.type(true), 'boolean') - assert.are_equal(utils.type(false), 'boolean') - end), - test('number', function () - assert.are_equal(utils.type(5), 'number') - assert.are_equal(utils.type(-3.02), 'number') - end), - test('string', function () - assert.are_equal(utils.type(''), 'string') - assert.are_equal(utils.type('asdf'), 'string') - end), - test('plain table', function () - assert.are_equal(utils.type({}), 'table') - end), - test('List', function () - assert.are_equal(utils.type(pandoc.List{}), 'List') - end), - test('Inline', function () - assert.are_equal(utils.type(pandoc.Str 'a'), 'Inline') - assert.are_equal(utils.type(pandoc.Emph 'emphasized'), 'Inline') - end), - test('Inlines', function () - assert.are_equal(utils.type(pandoc.Inlines{pandoc.Str 'a'}), 'Inlines') - assert.are_equal(utils.type(pandoc.Inlines{pandoc.Emph 'b'}), 'Inlines') - end), - test('Blocks', function () - assert.are_equal(utils.type(pandoc.Para 'a'), 'Block') - assert.are_equal(utils.type(pandoc.CodeBlock 'true'), 'Block') - end), - test('Inlines', function () - assert.are_equal(utils.type(pandoc.Blocks{'a'}), 'Blocks') - assert.are_equal(utils.type(pandoc.Blocks{pandoc.CodeBlock 'b'}), 'Blocks') - end), - }, - - group 'to_simple_table' { - test('convertes Table', function () - function simple_cell (blocks) - return { - attr = pandoc.Attr(), - alignment = "AlignDefault", - contents = blocks, - col_span = 1, - row_span = 1, - } - end - local tbl = pandoc.Table( - {long = {pandoc.Plain { - pandoc.Str "the", pandoc.Space(), pandoc.Str "caption"}}}, - {{pandoc.AlignDefault, nil}}, - pandoc.TableHead{pandoc.Row{simple_cell{pandoc.Plain "head1"}}}, - {{ - attr = pandoc.Attr(), - body = {pandoc.Row{simple_cell{pandoc.Plain "cell1"}}}, - head = {}, - row_head_columns = 0 - }}, - pandoc.TableFoot(), - pandoc.Attr() - ) - local stbl = utils.to_simple_table(tbl) - assert.are_equal('SimpleTable', stbl.t) - assert.are_equal('head1', utils.stringify(stbl.headers[1])) - assert.are_equal('cell1', utils.stringify(stbl.rows[1][1])) - assert.are_equal('the caption', utils.stringify(pandoc.Span(stbl.caption))) - end), - test('fails on para', function () - assert.is_falsy(pcall(utils.to_simple_table, pandoc.Para "nope")) - end), - }, - group 'from_simple_table' { - test('converts SimpleTable to Table', function () - local caption = {pandoc.Str "Overview"} - local aligns = {pandoc.AlignDefault, pandoc.AlignDefault} - local widths = {0, 0} -- let pandoc determine col widths - local headers = { - {pandoc.Plain "Language"}, - {pandoc.Plain "Typing"} - } - local rows = { - {{pandoc.Plain "Haskell"}, {pandoc.Plain "static"}}, - {{pandoc.Plain "Lua"}, {pandoc.Plain "Dynamic"}}, - } - local simple_table = pandoc.SimpleTable( - caption, - aligns, - widths, - headers, - rows - ) - local tbl = utils.from_simple_table(simple_table) - assert.are_equal("Table", tbl.t) - assert.are_same( - {pandoc.Plain(caption)}, - tbl.caption.long - ) - -- reversible - assert.are_same(simple_table, utils.to_simple_table(tbl)) - end), - test('empty caption', function () - local simple_table = pandoc.SimpleTable( - {}, - {pandoc.AlignDefault}, - {0}, - {{pandoc.Plain 'a'}}, - {{{pandoc.Plain 'b'}}} - ) - local tbl = utils.from_simple_table(simple_table) - assert.are_equal( - pandoc.Blocks{}, - tbl.caption.long - ) - assert.is_nil(tbl.caption.short) - end), - test('empty body', function () - local simple_table = pandoc.SimpleTable( - pandoc.Inlines('a nice caption'), - {pandoc.AlignDefault}, - {0}, - {{pandoc.Plain 'a'}}, - {} - ) - local tbl = utils.from_simple_table(simple_table) - tbl.bodies:map(print) - assert.are_same(pandoc.List(), tbl.bodies) - end), - } -} diff --git a/test/lua/module/pandoc.lua b/test/lua/module/pandoc.lua deleted file mode 100644 index 397182438..000000000 --- a/test/lua/module/pandoc.lua +++ /dev/null @@ -1,356 +0,0 @@ -local tasty = require 'tasty' - -local test = tasty.test_case -local group = tasty.test_group -local assert = tasty.assert - -function os_is_windows () - return package.config:sub(1,1) == '\\' -end - --- Constructor behavior is tested in the hslua-pandoc-types module, so --- we just make sure the functions are present. -return { - group 'Constructors' { - group 'Misc' { - test('pandoc.Attr is a function', function () - assert.are_equal(type(pandoc.Attr), 'function') - end), - test('pandoc.AttributeList is a function', function () - assert.are_equal(type(pandoc.AttributeList), 'function') - end), - test('pandoc.Blocks is a function', function () - assert.are_equal(type(pandoc.Blocks), 'function') - end), - test('pandoc.Citation is a function', function () - assert.are_equal(type(pandoc.Citation), 'function') - end), - test('pandoc.Inlines is a function', function () - assert.are_equal(type(pandoc.Inlines), 'function') - end), - test('pandoc.SimpleTable is a function', function () - assert.are_equal(type(pandoc.SimpleTable), 'function') - end), - test('pandoc.Meta is a function', function () - assert.are_equal(type(pandoc.Meta), 'function') - end), - test('pandoc.Pandoc is a function', function () - assert.are_equal(type(pandoc.Pandoc), 'function') - end), - }, - group "Inline elements" { - test('pandoc.AttributeList is a function', function () - assert.are_equal(type(pandoc.Cite), 'function') - end), - test('pandoc.AttributeList is a function', function () - assert.are_equal(type(pandoc.Code), 'function') - end), - test('pandoc.Emph is a function', function () - assert.are_equal(type(pandoc.Emph), 'function') - end), - test('pandoc.Image is a function', function () - assert.are_equal(type(pandoc.Image), 'function') - end), - test('pandoc.Link is a function', function () - assert.are_equal(type(pandoc.Link), 'function') - end), - test('pandoc.Math is a function', function () - assert.are_equal(type(pandoc.Math), 'function') - end), - test('pandoc.Note is a function', function () - assert.are_equal(type(pandoc.Note), 'function') - end), - test('pandoc.Quoted is a function', function () - assert.are_equal(type(pandoc.Quoted), 'function') - end), - test('pandoc.SmallCaps is a function', function () - assert.are_equal(type(pandoc.SmallCaps), 'function') - end), - test('pandoc.SoftBreak is a function', function () - assert.are_equal(type(pandoc.SoftBreak), 'function') - end), - test('pandoc.Span is a function', function () - assert.are_equal(type(pandoc.Span), 'function') - end), - test('pandoc.Str is a function', function () - assert.are_equal(type(pandoc.Str), 'function') - end), - test('pandoc.Strikeout is a function', function () - assert.are_equal(type(pandoc.Strikeout), 'function') - end), - test('pandoc.Strong is a function', function () - assert.are_equal(type(pandoc.Strong), 'function') - end), - test('pandoc.Subscript is a function', function () - assert.are_equal(type(pandoc.Subscript), 'function') - end), - test('pandoc.Superscript is a function', function () - assert.are_equal(type(pandoc.Superscript), 'function') - end), - test('pandoc.Underline is a function', function () - assert.are_equal(type(pandoc.Underline), 'function') - end), - }, - group "Block elements" { - test('pandoc.BlockQuote is a function', function () - assert.are_equal(type(pandoc.BlockQuote), 'function') - end), - test('pandoc.BulletList is a function', function () - assert.are_equal(type(pandoc.BulletList), 'function') - end), - test('pandoc.CodeBlock is a function', function () - assert.are_equal(type(pandoc.CodeBlock), 'function') - end), - test('pandoc.DefinitionList is a function', function () - assert.are_equal(type(pandoc.DefinitionList), 'function') - end), - test('pandoc.Div is a function', function () - assert.are_equal(type(pandoc.Div), 'function') - end), - test('pandoc.Header is a function', function () - assert.are_equal(type(pandoc.Header), 'function') - end), - test('pandoc.LineBlock is a function', function () - assert.are_equal(type(pandoc.LineBlock), 'function') - end), - test('pandoc.Null is a function', function () - assert.are_equal(type(pandoc.Null), 'function') - end), - test('pandoc.OrderedList is a function', function () - assert.are_equal(type(pandoc.OrderedList), 'function') - end), - test('pandoc.Para is a function', function () - assert.are_equal(type(pandoc.Para), 'function') - end), - test('pandoc.Plain is a function', function () - assert.are_equal(type(pandoc.Plain), 'function') - end), - test('pandoc.RawBlock is a function', function () - assert.are_equal(type(pandoc.Plain), 'function') - end), - test('pandoc.Table is a function', function () - assert.are_equal(type(pandoc.Table), 'function') - end), - } - }, - group 'MetaValue elements' { - test('MetaList elements behave like lists', function () - local metalist = pandoc.MetaList{} - assert.are_equal(type(metalist.insert), 'function') - assert.are_equal(type(metalist.remove), 'function') - end), - test('`tag` is an alias for `t``', function () - assert.are_equal((pandoc.MetaList{}).tag, (pandoc.MetaList{}).t) - assert.are_equal((pandoc.MetaMap{}).tag, (pandoc.MetaMap{}).t) - assert.are_equal((pandoc.MetaInlines{}).tag, (pandoc.MetaInlines{}).t) - assert.are_equal((pandoc.MetaBlocks{}).tag, (pandoc.MetaBlocks{}).t) - end), - }, - group 'Meta' { - test('inline list is treated as MetaInlines', function () - local meta = pandoc.Pandoc({}, {test = {pandoc.Emph 'check'}}).meta - assert.are_same(meta.test, {pandoc.Emph{pandoc.Str 'check'}}) - end), - test('inline element is treated as MetaInlines singleton', function () - local meta = pandoc.Pandoc({}, {test = pandoc.Emph 'check'}).meta - assert.are_same(meta.test, {pandoc.Emph{pandoc.Str 'check'}}) - end), - test('block list is treated as MetaBlocks', function () - local meta = pandoc.Pandoc({}, {test = {pandoc.Plain 'check'}}).meta - assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}}) - end), - test('block element is treated as MetaBlocks singleton', function () - local meta = pandoc.Pandoc({}, {test = pandoc.Plain 'check'}).meta - assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}}) - end), - }, - group 'Other types' { - group 'ReaderOptions' { - test('returns a userdata value', function () - local opts = pandoc.ReaderOptions {} - assert.are_equal(type(opts), 'userdata') - end), - test('can construct from table', function () - local opts = pandoc.ReaderOptions {columns = 66} - assert.are_equal(opts.columns, 66) - end), - test('can construct from other ReaderOptions value', function () - local orig = pandoc.ReaderOptions{columns = 65} - local copy = pandoc.ReaderOptions(orig) - for k, v in pairs(orig) do - assert.are_same(copy[k], v) - end - assert.are_equal(copy.columns, 65) - end), - }, - }, - - group 'clone' { - test('clones Attr', function () - local attr = pandoc.Attr('test', {'my-class'}, {foo = 'bar'}) - local cloned = attr:clone() - attr.identifier = '' - attr.classes = {} - attr.attributes = {} - assert.are_same(cloned.identifier, 'test') - assert.are_same(cloned.classes, {'my-class'}) - assert.are_same(cloned.attributes.foo, 'bar') - end), - test('clones ListAttributes', function () - local la = pandoc.ListAttributes(2, pandoc.DefaultStyle, pandoc.Period) - local cloned = la:clone() - la.start = 9 - assert.are_same(cloned.start, 2) - end), - test('clones Para', function () - local para = pandoc.Para {pandoc.Str 'Hello'} - local cloned = para:clone() - para.content[1].text = 'bye' - assert.are_same(cloned, pandoc.Para {pandoc.Str 'Hello'}) - end), - test('clones Str', function () - local str = pandoc.Str 'Hello' - local cloned = str:clone() - str.text = 'bye' - assert.are_same(cloned.text, 'Hello') - end), - test('clones Citation', function () - local cite = pandoc.Citation('leibniz', pandoc.AuthorInText) - local cloned = cite:clone() - cite.id = 'newton' - assert.are_same(cloned.id, 'leibniz') - assert.are_same(cite.id, 'newton') - assert.are_same(cite.mode, cloned.mode) - end), - }, - - group 'pipe' { - test('external string processing', function () - if os_is_windows() then - local pipe_result = pandoc.pipe('find', {'hi'}, 'hi') - assert.are_equal('hi', pipe_result:match '%a+') - else - local pipe_result = pandoc.pipe('tr', {'a', 'b'}, 'abc') - assert.are_equal('bbc', pipe_result:match '%a+') - end - end), - test('failing pipe', function () - if os_is_windows() then - local success, err = pcall(pandoc.pipe, 'find', {'/a'}, 'hi') - assert.is_falsy(success) - assert.are_equal('find', err.command) - assert.is_truthy(err.error_code ~= 0) - else - local success, err = pcall(pandoc.pipe, 'false', {}, 'abc') - assert.is_falsy(success) - assert.are_equal('false', err.command) - assert.are_equal(1, err.error_code) - assert.are_equal('', err.output) - end - end) - }, - - group 'read' { - test('Markdown', function () - local valid_markdown = '*Hello*, World!\n' - local expected = pandoc.Pandoc({ - pandoc.Para { - pandoc.Emph { pandoc.Str 'Hello' }, - pandoc.Str ',', - pandoc.Space(), - pandoc.Str 'World!' - } - }) - assert.are_same(expected, pandoc.read(valid_markdown)) - end), - test('unsupported extension', function () - assert.error_matches( - function () pandoc.read('foo', 'gfm+empty_paragraphs') end, - 'Extension empty_paragraphs not supported for gfm' - ) - end), - test('read with other indented code classes', function() - local indented_code = ' return true' - local expected = pandoc.Pandoc({ - pandoc.CodeBlock('return true', {class='foo'}) - }) - assert.are_same( - expected, - pandoc.read(indented_code, 'markdown', {indented_code_classes={'foo'}}) - ) - end), - test('can read epub', function () - local epub = io.open('lua/module/tiny.epub', 'rb') - local blocks = pandoc.read(epub:read'a', 'epub').blocks - assert.are_equal( - blocks[#blocks], - pandoc.Para { pandoc.Emph 'EPUB' } - ) - end), - test('failing read', function () - assert.error_matches( - function () pandoc.read('foo', 'nosuchreader') end, - 'Unknown reader: nosuchreader' - ) - end) - }, - - group 'walk_block' { - test('block walking order', function () - local acc = {} - local nested_nums = pandoc.Div { - pandoc.Para{pandoc.Str'1'}, - pandoc.Div{ - pandoc.Para{pandoc.Str'2'}, - pandoc.Para{pandoc.Str'3'} - }, - pandoc.Para{pandoc.Str'4'} - } - pandoc.walk_block( - nested_nums, - {Para = function (p) table.insert(acc, p.content[1].text) end} - ) - assert.are_equal('1234', table.concat(acc)) - end) - }, - - group 'walk_inline' { - test('inline walking order', function () - local acc = {} - local nested_nums = pandoc.Span { - pandoc.Str'1', - pandoc.Emph { - pandoc.Str'2', - pandoc.Str'3' - }, - pandoc.Str'4' - } - pandoc.walk_inline( - nested_nums, - {Str = function (s) table.insert(acc, s.text) end} - ) - assert.are_equal('1234', table.concat(acc)) - end) - }, - - group 'Marshal' { - group 'Inlines' { - test('Strings are broken into words', function () - assert.are_equal( - pandoc.Emph 'Nice, init?', - pandoc.Emph{pandoc.Str 'Nice,', pandoc.Space(), pandoc.Str 'init?'} - ) - end) - }, - group 'Blocks' { - test('Strings are broken into words and wrapped in Plain', function () - assert.are_equal( - pandoc.Div{ - pandoc.Plain{pandoc.Str 'Nice,', pandoc.Space(), pandoc.Str 'init?'} - }, - pandoc.Div{'Nice, init?'} - ) - end) - } - } -} diff --git a/test/lua/module/partial.test b/test/lua/module/partial.test deleted file mode 100644 index e69de29bb..000000000 --- a/test/lua/module/partial.test +++ /dev/null diff --git a/test/lua/module/tiny.epub b/test/lua/module/tiny.epub Binary files differdeleted file mode 100644 index 9e92202b7..000000000 --- a/test/lua/module/tiny.epub +++ /dev/null diff --git a/test/lua/plain-to-para.lua b/test/lua/plain-to-para.lua deleted file mode 100644 index aa12a97d3..000000000 --- a/test/lua/plain-to-para.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - { Plain = function (elem) - return pandoc.Para(elem.content) - end, - } -} diff --git a/test/lua/require-file.lua b/test/lua/require-file.lua deleted file mode 100644 index d610e5266..000000000 --- a/test/lua/require-file.lua +++ /dev/null @@ -1,2 +0,0 @@ -package.path = package.path .. ';lua/?.lua' -require 'script-name' diff --git a/test/lua/script-name.lua b/test/lua/script-name.lua deleted file mode 100644 index 4b5a223f0..000000000 --- a/test/lua/script-name.lua +++ /dev/null @@ -1,3 +0,0 @@ -function Para (_) - return pandoc.Para{pandoc.Str(PANDOC_SCRIPT_FILE)} -end diff --git a/test/lua/single-to-double-quoted.lua b/test/lua/single-to-double-quoted.lua deleted file mode 100644 index b985b215c..000000000 --- a/test/lua/single-to-double-quoted.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - Quoted = function (elem) - if elem.quotetype == "SingleQuote" then - elem.quotetype = "DoubleQuote" - end - return elem - end, - } -} diff --git a/test/lua/smallcaps-title.lua b/test/lua/smallcaps-title.lua deleted file mode 100644 index b839ee131..000000000 --- a/test/lua/smallcaps-title.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - { - Meta = function(meta) - -- The call to `MetaInlines` is redundant and used for testing purposes - -- only. The explicit use of a MetaValue constructor is only useful when - -- used with an empty table: `MetaInlines{}` is read differently than - -- `MetaBlocks{}`. - meta.title = pandoc.MetaInlines{pandoc.SmallCaps(meta.title)} - return meta - end - } -} diff --git a/test/lua/smart-constructors.lua b/test/lua/smart-constructors.lua deleted file mode 100644 index 6e579a12f..000000000 --- a/test/lua/smart-constructors.lua +++ /dev/null @@ -1,10 +0,0 @@ --- Test that constructors are "smart" in that they autoconvert --- types where sensible. -function Para (_) - return { - pandoc.BulletList{pandoc.Para "Hello", pandoc.Para "World"}, - pandoc.DefinitionList{{"foo", pandoc.Para "placeholder"}}, - pandoc.LineBlock{"Moin", "Welt"}, - pandoc.OrderedList{pandoc.Plain{pandoc.Str "one"}, pandoc.Plain "two"} - } -end diff --git a/test/lua/strmacro.lua b/test/lua/strmacro.lua deleted file mode 100644 index a2711798a..000000000 --- a/test/lua/strmacro.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - { - Str = function (elem) - if elem.text == "{{helloworld}}" then - return pandoc.Emph {pandoc.Str "Hello, World"} - else - return elem - end - end, - } -} diff --git a/test/lua/undiv.lua b/test/lua/undiv.lua deleted file mode 100644 index 1cbb6d30e..000000000 --- a/test/lua/undiv.lua +++ /dev/null @@ -1,3 +0,0 @@ -function Div(el) - return el.content -end diff --git a/test/lua/uppercase-header.lua b/test/lua/uppercase-header.lua deleted file mode 100644 index 8e86911c0..000000000 --- a/test/lua/uppercase-header.lua +++ /dev/null @@ -1,9 +0,0 @@ -local text = require 'text' - -local function str_to_uppercase (s) - return pandoc.Str(text.upper(s.text)) -end - -function Header (el) - return pandoc.walk_block(el, {Str = str_to_uppercase}) -end diff --git a/test/tables.custom b/test/tables.custom deleted file mode 100644 index ce0268edf..000000000 --- a/test/tables.custom +++ /dev/null @@ -1,200 +0,0 @@ -<p>Simple table with caption:</p> - -<table> -<caption>Demonstration of simple table syntax.</caption> -<tr class="header"> -<th align="right">Right</th> -<th align="left">Left</th> -<th align="center">Center</th> -<th align="left">Default</th> -</tr> -<tr class="odd"> -<td align="right">12</td> -<td align="left">12</td> -<td align="center">12</td> -<td align="left">12</td> -</tr> -<tr class="even"> -<td align="right">123</td> -<td align="left">123</td> -<td align="center">123</td> -<td align="left">123</td> -</tr> -<tr class="odd"> -<td align="right">1</td> -<td align="left">1</td> -<td align="center">1</td> -<td align="left">1</td> -</tr> -</table> - -<p>Simple table without caption:</p> - -<table> -<tr class="header"> -<th align="right">Right</th> -<th align="left">Left</th> -<th align="center">Center</th> -<th align="left">Default</th> -</tr> -<tr class="odd"> -<td align="right">12</td> -<td align="left">12</td> -<td align="center">12</td> -<td align="left">12</td> -</tr> -<tr class="even"> -<td align="right">123</td> -<td align="left">123</td> -<td align="center">123</td> -<td align="left">123</td> -</tr> -<tr class="odd"> -<td align="right">1</td> -<td align="left">1</td> -<td align="center">1</td> -<td align="left">1</td> -</tr> -</table> - -<p>Simple table indented two spaces:</p> - -<table> -<caption>Demonstration of simple table syntax.</caption> -<tr class="header"> -<th align="right">Right</th> -<th align="left">Left</th> -<th align="center">Center</th> -<th align="left">Default</th> -</tr> -<tr class="odd"> -<td align="right">12</td> -<td align="left">12</td> -<td align="center">12</td> -<td align="left">12</td> -</tr> -<tr class="even"> -<td align="right">123</td> -<td align="left">123</td> -<td align="center">123</td> -<td align="left">123</td> -</tr> -<tr class="odd"> -<td align="right">1</td> -<td align="left">1</td> -<td align="center">1</td> -<td align="left">1</td> -</tr> -</table> - -<p>Multiline table with caption:</p> - -<table> -<caption>Here’s the caption. -It may span multiple lines.</caption> -<col width="15%" /> -<col width="14%" /> -<col width="16%" /> -<col width="35%" /> -<tr class="header"> -<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 class="odd"> -<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 class="even"> -<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>Multiline table without caption:</p> - -<table> -<col width="15%" /> -<col width="14%" /> -<col width="16%" /> -<col width="35%" /> -<tr class="header"> -<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 class="odd"> -<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 class="even"> -<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>Table without column headers:</p> - -<table> -<tr class="odd"> -<td align="right">12</td> -<td align="left">12</td> -<td align="center">12</td> -<td align="right">12</td> -</tr> -<tr class="even"> -<td align="right">123</td> -<td align="left">123</td> -<td align="center">123</td> -<td align="right">123</td> -</tr> -<tr class="odd"> -<td align="right">1</td> -<td align="left">1</td> -<td align="center">1</td> -<td align="right">1</td> -</tr> -</table> - -<p>Multiline table without column headers:</p> - -<table> -<col width="15%" /> -<col width="14%" /> -<col width="16%" /> -<col width="35%" /> -<tr class="odd"> -<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 class="even"> -<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> diff --git a/test/test-pandoc.hs b/test/test-pandoc.hs index 467e264f0..73841d29b 100644 --- a/test/test-pandoc.hs +++ b/test/test-pandoc.hs @@ -11,8 +11,6 @@ import Text.Pandoc.Scripting (noEngine) import GHC.IO.Encoding import Test.Tasty import qualified Tests.Command -import qualified Tests.Lua -import qualified Tests.Lua.Module import qualified Tests.Old import qualified Tests.Readers.Creole import qualified Tests.Readers.Docx @@ -100,10 +98,6 @@ tests pandocPath = testGroup "pandoc tests" , testGroup "FB2" Tests.Readers.FB2.tests , testGroup "DokuWiki" Tests.Readers.DokuWiki.tests ] - , testGroup "Lua" - [ testGroup "Lua filters" Tests.Lua.tests - , testGroup "Lua modules" Tests.Lua.Module.tests - ] ] main :: IO () @@ -114,7 +108,7 @@ main = do "--emulate":args' -> -- emulate pandoc executable E.catch (parseOptionsFromArgs (options noEngine) defaultOpts "pandoc" args' - >>= convertWithOpts) + >>= convertWithOpts noEngine) (handleError . Left) _ -> inDirectory "test" $ do fp <- getExecutablePath diff --git a/test/writer.custom b/test/writer.custom deleted file mode 100644 index eb53363fa..000000000 --- a/test/writer.custom +++ /dev/null @@ -1,781 +0,0 @@ -<p>This is a set of tests for pandoc. Most of them are adapted from -John Gruber’s markdown test suite.</p> - -<hr/> - -<h1 id="headers">Headers</h1> - -<h2 id="level-2-with-an-embedded-link">Level 2 with an <a href="/url" title="">embedded link</a></h2> - -<h3 id="level-3-with-emphasis">Level 3 with <em>emphasis</em></h3> - -<h4 id="level-4">Level 4</h4> - -<h5 id="level-5">Level 5</h5> - -<h1 id="level-1">Level 1</h1> - -<h2 id="level-2-with-emphasis">Level 2 with <em>emphasis</em></h2> - -<h3 id="level-3">Level 3</h3> - -<p>with no blank line</p> - -<h2 id="level-2">Level 2</h2> - -<p>with no blank line</p> - -<hr/> - -<h1 id="paragraphs">Paragraphs</h1> - -<p>Here’s a regular paragraph.</p> - -<p>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.</p> - -<p>Here’s one with a bullet. -* criminey.</p> - -<p>There should be a hard line break<br/>here.</p> - -<hr/> - -<h1 id="block-quotes">Block Quotes</h1> - -<p>E-mail style:</p> - -<blockquote> -<p>This is a block quote. -It is pretty short.</p> -</blockquote> - -<blockquote> -<p>Code in a block quote:</p> - -<pre><code>sub status { - print "working"; -}</code></pre> - -<p>A list:</p> - -<ol> -<li>item one</li> -<li>item two</li> -</ol> - -<p>Nested block quotes:</p> - -<blockquote> -<p>nested</p> -</blockquote> - -<blockquote> -<p>nested</p> -</blockquote> -</blockquote> - -<p>This should not be a block quote: 2 -> 1.</p> - -<p>And a following paragraph.</p> - -<hr/> - -<h1 id="code-blocks">Code Blocks</h1> - -<p>Code:</p> - -<pre><code>---- (should be four hyphens) - -sub status { - print "working"; -} - -this code block is indented by one tab</code></pre> - -<p>And:</p> - -<pre><code> this code block is indented by two tabs - -These should not be escaped: \$ \\ \> \[ \{</code></pre> - -<hr/> - -<h1 id="lists">Lists</h1> - -<h2 id="unordered">Unordered</h2> - -<p>Asterisks tight:</p> - -<ul> -<li>asterisk 1</li> -<li>asterisk 2</li> -<li>asterisk 3</li> -</ul> - -<p>Asterisks loose:</p> - -<ul> -<li><p>asterisk 1</p></li> -<li><p>asterisk 2</p></li> -<li><p>asterisk 3</p></li> -</ul> - -<p>Pluses tight:</p> - -<ul> -<li>Plus 1</li> -<li>Plus 2</li> -<li>Plus 3</li> -</ul> - -<p>Pluses loose:</p> - -<ul> -<li><p>Plus 1</p></li> -<li><p>Plus 2</p></li> -<li><p>Plus 3</p></li> -</ul> - -<p>Minuses tight:</p> - -<ul> -<li>Minus 1</li> -<li>Minus 2</li> -<li>Minus 3</li> -</ul> - -<p>Minuses loose:</p> - -<ul> -<li><p>Minus 1</p></li> -<li><p>Minus 2</p></li> -<li><p>Minus 3</p></li> -</ul> - -<h2 id="ordered">Ordered</h2> - -<p>Tight:</p> - -<ol> -<li>First</li> -<li>Second</li> -<li>Third</li> -</ol> - -<p>and:</p> - -<ol> -<li>One</li> -<li>Two</li> -<li>Three</li> -</ol> - -<p>Loose using tabs:</p> - -<ol> -<li><p>First</p></li> -<li><p>Second</p></li> -<li><p>Third</p></li> -</ol> - -<p>and using spaces:</p> - -<ol> -<li><p>One</p></li> -<li><p>Two</p></li> -<li><p>Three</p></li> -</ol> - -<p>Multiple paragraphs:</p> - -<ol> -<li><p>Item 1, graf one.</p> - -<p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s -back.</p></li> -<li><p>Item 2.</p></li> -<li><p>Item 3.</p></li> -</ol> - -<h2 id="nested">Nested</h2> - -<ul> -<li>Tab - -<ul> -<li>Tab - -<ul> -<li>Tab</li> -</ul></li> -</ul></li> -</ul> - -<p>Here’s another:</p> - -<ol> -<li>First</li> -<li>Second: - -<ul> -<li>Fee</li> -<li>Fie</li> -<li>Foe</li> -</ul></li> -<li>Third</li> -</ol> - -<p>Same thing but with paragraphs:</p> - -<ol> -<li><p>First</p></li> -<li><p>Second:</p> - -<ul> -<li>Fee</li> -<li>Fie</li> -<li>Foe</li> -</ul></li> -<li><p>Third</p></li> -</ol> - -<h2 id="tabs-and-spaces">Tabs and spaces</h2> - -<ul> -<li><p>this is a list item -indented with tabs</p></li> -<li><p>this is a list item -indented with spaces</p> - -<ul> -<li><p>this is an example list item -indented with tabs</p></li> -<li><p>this is an example list item -indented with spaces</p></li> -</ul></li> -</ul> - -<h2 id="fancy-list-markers">Fancy list markers</h2> - -<ol> -<li><p>begins with 2</p></li> -<li><p>and now 3</p> - -<p>with a continuation</p> - -<ol> -<li>sublist with roman numerals, -starting with 4</li> -<li>more items - -<ol> -<li>a subsublist</li> -<li>a subsublist</li> -</ol></li> -</ol></li> -</ol> - -<p>Nesting:</p> - -<ol> -<li>Upper Alpha - -<ol> -<li>Upper Roman. - -<ol> -<li>Decimal start with 6 - -<ol> -<li>Lower alpha with paren</li> -</ol></li> -</ol></li> -</ol></li> -</ol> - -<p>Autonumbering:</p> - -<ol> -<li>Autonumber.</li> -<li>More. - -<ol> -<li>Nested.</li> -</ol></li> -</ol> - -<p>Should not be a list item:</p> - -<p>M.A. 2007</p> - -<p>B. Williams</p> - -<hr/> - -<h1 id="definition-lists">Definition Lists</h1> - -<p>Tight using spaces:</p> - -<dl> -<dt>apple</dt> -<dd>red fruit</dd> -<dt>orange</dt> -<dd>orange fruit</dd> -<dt>banana</dt> -<dd>yellow fruit</dd> -</dl> - -<p>Tight using tabs:</p> - -<dl> -<dt>apple</dt> -<dd>red fruit</dd> -<dt>orange</dt> -<dd>orange fruit</dd> -<dt>banana</dt> -<dd>yellow fruit</dd> -</dl> - -<p>Loose:</p> - -<dl> -<dt>apple</dt> -<dd><p>red fruit</p></dd> -<dt>orange</dt> -<dd><p>orange fruit</p></dd> -<dt>banana</dt> -<dd><p>yellow fruit</p></dd> -</dl> - -<p>Multiple blocks with italics:</p> - -<dl> -<dt><em>apple</em></dt> -<dd><p>red fruit</p> - -<p>contains seeds, -crisp, pleasant to taste</p></dd> -<dt><em>orange</em></dt> -<dd><p>orange fruit</p> - -<pre><code>{ orange code block }</code></pre> - -<blockquote> -<p>orange block quote</p> -</blockquote></dd> -</dl> - -<p>Multiple definitions, tight:</p> - -<dl> -<dt>apple</dt> -<dd>red fruit</dd> -<dd>computer</dd> -<dt>orange</dt> -<dd>orange fruit</dd> -<dd>bank</dd> -</dl> - -<p>Multiple definitions, loose:</p> - -<dl> -<dt>apple</dt> -<dd><p>red fruit</p></dd> -<dd><p>computer</p></dd> -<dt>orange</dt> -<dd><p>orange fruit</p></dd> -<dd><p>bank</p></dd> -</dl> - -<p>Blank line after term, indented marker, alternate markers:</p> - -<dl> -<dt>apple</dt> -<dd><p>red fruit</p></dd> -<dd><p>computer</p></dd> -<dt>orange</dt> -<dd><p>orange fruit</p> - -<ol> -<li>sublist</li> -<li>sublist</li> -</ol></dd> -</dl> - -<h1 id="html-blocks">HTML Blocks</h1> - -<p>Simple block on one line:</p> - -<div> -foo</div> - -<p>And nested without indentation:</p> - -<div> -<div> -<div> -<p>foo</p></div></div> - -<div> -bar</div></div> - -<p>Interpreted markdown in a table:</p> - -<table> - -<tr> - -<td> - -This is <em>emphasized</em> - -</td> - -<td> - -And this is <strong>strong</strong> - -</td> - -</tr> - -</table> - -<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script> - -<p>Here’s a simple block:</p> - -<div> -<p>foo</p></div> - -<p>This should be a code block, though:</p> - -<pre><code><div> - foo -</div></code></pre> - -<p>As should this:</p> - -<pre><code><div>foo</div></code></pre> - -<p>Now, nested:</p> - -<div> -<div> -<div> -foo</div></div></div> - -<p>This should just be an HTML comment:</p> - -<!-- Comment --> - -<p>Multiline:</p> - -<!-- -Blah -Blah ---> - -<!-- - This is another comment. ---> - -<p>Code block:</p> - -<pre><code><!-- Comment --></code></pre> - -<p>Just plain comment, with trailing spaces on the line:</p> - -<!-- foo --> - -<p>Code:</p> - -<pre><code><hr /></code></pre> - -<p>Hr’s:</p> - -<hr> - -<hr /> - -<hr /> - -<hr> - -<hr /> - -<hr /> - -<hr class="foo" id="bar" /> - -<hr class="foo" id="bar" /> - -<hr class="foo" id="bar"> - -<hr/> - -<h1 id="inline-markup">Inline Markup</h1> - -<p>This is <em>emphasized</em>, and so <em>is this</em>.</p> - -<p>This is <strong>strong</strong>, and so <strong>is this</strong>.</p> - -<p>An <em><a href="/url" title="">emphasized link</a></em>.</p> - -<p><strong><em>This is strong and em.</em></strong></p> - -<p>So is <strong><em>this</em></strong> word.</p> - -<p><strong><em>This is strong and em.</em></strong></p> - -<p>So is <strong><em>this</em></strong> word.</p> - -<p>This is code: <code>></code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code><html></code>.</p> - -<p><del>This is <em>strikeout</em>.</del></p> - -<p>Superscripts: a<sup>bc</sup>d a<sup><em>hello</em></sup> a<sup>hello there</sup>.</p> - -<p>Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.</p> - -<p>These should not be superscripts or subscripts, -because of the unescaped spaces: a^b c^d, a~b c~d.</p> - -<hr/> - -<h1 id="smart-quotes-ellipses-dashes">Smart quotes, ellipses, dashes</h1> - -<p>“Hello,” said the spider. “‘Shelob’ is my name.”</p> - -<p>‘A’, ‘B’, and ‘C’ are letters.</p> - -<p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. -So is ‘pine.’</p> - -<p>‘He said, “I want to go.”’ Were you alive in the -70’s?</p> - -<p>Here is some quoted ‘<code>code</code>’ and a “<a href="http://example.com/?foo=1&bar=2" title="">quoted link</a>”.</p> - -<p>Some dashes: one—two — three—four — five.</p> - -<p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p> - -<p>Ellipses…and…and….</p> - -<hr/> - -<h1 id="latex">LaTeX</h1> - -<ul> -<li></li> -<li>\(2+2=4\)</li> -<li>\(x \in y\)</li> -<li>\(\alpha \wedge \omega\)</li> -<li>\(223\)</li> -<li>\(p\)-Tree</li> -<li>Here’s some display math: -\[\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}\]</li> -<li>Here’s one that has a line break in it: \(\alpha + \omega \times x^2\).</li> -</ul> - -<p>These shouldn’t be math:</p> - -<ul> -<li>To get the famous equation, write <code>$e = mc^2$</code>.</li> -<li>$22,000 is a <em>lot</em> of money. So is $34,000. -(It worked if “lot” is emphasized.)</li> -<li>Shoes ($20) and socks ($5).</li> -<li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li> -</ul> - -<p>Here’s a LaTeX table:</p> - - - -<hr/> - -<h1 id="special-characters">Special Characters</h1> - -<p>Here is some unicode:</p> - -<ul> -<li>I hat: Î</li> -<li>o umlaut: ö</li> -<li>section: §</li> -<li>set membership: ∈</li> -<li>copyright: ©</li> -</ul> - -<p>AT&T has an ampersand in their name.</p> - -<p>AT&T is another way to write it.</p> - -<p>This & that.</p> - -<p>4 < 5.</p> - -<p>6 > 5.</p> - -<p>Backslash: \</p> - -<p>Backtick: `</p> - -<p>Asterisk: *</p> - -<p>Underscore: _</p> - -<p>Left brace: {</p> - -<p>Right brace: }</p> - -<p>Left bracket: [</p> - -<p>Right bracket: ]</p> - -<p>Left paren: (</p> - -<p>Right paren: )</p> - -<p>Greater-than: ></p> - -<p>Hash: #</p> - -<p>Period: .</p> - -<p>Bang: !</p> - -<p>Plus: +</p> - -<p>Minus: -</p> - -<hr/> - -<h1 id="links">Links</h1> - -<h2 id="explicit">Explicit</h2> - -<p>Just a <a href="/url/" title="">URL</a>.</p> - -<p><a href="/url/" title="title">URL and title</a>.</p> - -<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p> - -<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p> - -<p><a href="/url/" title="title with "quotes" in it">URL and title</a></p> - -<p><a href="/url/" title="title with single quotes">URL and title</a></p> - -<p><a href="/url/with_underscore" title="">with_underscore</a></p> - -<p><a href="mailto:[email protected]" title="">Email link</a></p> - -<p><a href="" title="">Empty</a>.</p> - -<h2 id="reference">Reference</h2> - -<p>Foo <a href="/url/" title="">bar</a>.</p> - -<p>With <a href="/url/" title="">embedded [brackets]</a>.</p> - -<p><a href="/url/" title="">b</a> by itself should be a link.</p> - -<p>Indented <a href="/url" title="">once</a>.</p> - -<p>Indented <a href="/url" title="">twice</a>.</p> - -<p>Indented <a href="/url" title="">thrice</a>.</p> - -<p>This should [not][] be a link.</p> - -<pre><code>[not]: /url</code></pre> - -<p>Foo <a href="/url/" title="Title with "quotes" inside">bar</a>.</p> - -<p>Foo <a href="/url/" title="Title with "quote" inside">biz</a>.</p> - -<h2 id="with-ampersands">With ampersands</h2> - -<p>Here’s a <a href="http://example.com/?foo=1&bar=2" title="">link with an ampersand in the URL</a>.</p> - -<p>Here’s a link with an amersand in the link text: <a href="http://att.com/" title="AT&T">AT&T</a>.</p> - -<p>Here’s an <a href="/script?foo=1&bar=2" title="">inline link</a>.</p> - -<p>Here’s an <a href="/script?foo=1&bar=2" title="">inline link in pointy braces</a>.</p> - -<h2 id="autolinks">Autolinks</h2> - -<p>With an ampersand: <a href="http://example.com/?foo=1&bar=2" title="" class="uri">http://example.com/?foo=1&bar=2</a></p> - -<ul> -<li>In a list?</li> -<li><a href="http://example.com/" title="" class="uri">http://example.com/</a></li> -<li>It should.</li> -</ul> - -<p>An e-mail address: <a href="mailto:[email protected]" title="" class="email">[email protected]</a></p> - -<blockquote> -<p>Blockquoted: <a href="http://example.com/" title="" class="uri">http://example.com/</a></p> -</blockquote> - -<p>Auto-links should not occur here: <code><http://example.com/></code></p> - -<pre><code>or here: <http://example.com/></code></pre> - -<hr/> - -<h1 id="images">Images</h1> - -<p>From “Voyage dans la Lune” by Georges Melies (1902):</p> - -<figure> -<img src="lalune.jpg" id="" alt="lalune"/><figcaption>lalune</figcaption> -</figure> - -<p>Here is a movie <img src="movie.jpg" title=""/> icon.</p> - -<hr/> - -<h1 id="footnotes">Footnotes</h1> - -<p>Here is a footnote reference,<a id="fnref1" href="#fn1"><sup>1</sup></a> and another.<a id="fnref2" href="#fn2"><sup>2</sup></a> -This should <em>not</em> be a footnote reference, because it -contains a space.[^my note] Here is an inline note.<a id="fnref3" href="#fn3"><sup>3</sup></a></p> - -<blockquote> -<p>Notes can go in quotes.<a id="fnref4" href="#fn4"><sup>4</sup></a></p> -</blockquote> - -<ol> -<li>And in list items.<a id="fnref5" href="#fn5"><sup>5</sup></a></li> -</ol> - -<p>This paragraph should not be part of the note, as it is not indented.</p> -<ol class="footnotes"> -<li id="fn1"><p>Here is the footnote. It can go anywhere after the footnote -reference. It need not be placed at the end of the document. <a href="#fnref1">↩</a></p></li> -<li id="fn2"><p>Here’s the long note. This one contains multiple -blocks.</p> - -<p>Subsequent blocks are indented to show that they belong to the -footnote (as with list items).</p> - -<pre><code> { <code> }</code></pre> - -<p>If you want, you can indent every line, but you can also be -lazy and just indent the first line of each block. <a href="#fnref2">↩</a></p></li> -<li id="fn3"><p>This -is <em>easier</em> to type. Inline notes may contain -<a href="http://google.com" title="">links</a> and <code>]</code> verbatim characters, -as well as [bracketed text]. <a href="#fnref3">↩</a></p></li> -<li id="fn4"><p>In quote. <a href="#fnref4">↩</a></p></li> -<li id="fn5"><p>In list. <a href="#fnref5">↩</a></p></li> -</ol> |
