diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-04-14 23:24:52 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-04-14 23:43:59 +0200 |
commit | 3aeed816e163b1ad3925caff0496fa05a63d1369 (patch) | |
tree | 7042a865cdb02886c36fa1f85d53667a18467d30 /test | |
parent | eb8de6514b1ed44087a1d98a2cb8745b2903d98b (diff) | |
download | pandoc-3aeed816e163b1ad3925caff0496fa05a63d1369.tar.gz |
Lua filter: allow shorthand functions for math and quoted
Allow to use functions named `SingleQuoted`, `DoubleQuoted`,
`DisplayMath`, and `InlineMath` in filters.
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Lua.hs | 35 | ||||
-rw-r--r-- | test/lua/single-to-double-quoted.lua | 7 |
2 files changed, 28 insertions, 14 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 4196ff4b7..80c733751 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -8,15 +8,28 @@ import Test.Tasty.HUnit (Assertion, assertEqual, testCase) import Test.Tasty.QuickCheck (ioProperty, testProperty) import Text.Pandoc.Arbitrary () import Text.Pandoc.Definition (Block, Inline, Meta, Pandoc) -import Text.Pandoc.Builder ( (<>), bulletList, doc, emph, linebreak, rawBlock - , para, plain, space, str, strong) +import Text.Pandoc.Builder ( (<>), bulletList, doc, doubleQuoted, emph + , linebreak, rawBlock, singleQuoted, para, plain + , space, str, strong) import Text.Pandoc.Lua import qualified Scripting.Lua as Lua tests :: [TestTree] tests = - [ testCase "macro expansion via filter" $ + [ testProperty "inline elements can be round-tripped through the lua stack" $ + \x -> ioProperty (roundtripEqual (x::Inline)) + + , testProperty "block elements can be round-tripped through the lua stack" $ + \x -> ioProperty (roundtripEqual (x::Block)) + + , testProperty "meta blocks can be round-tripped through the lua stack" $ + \x -> ioProperty (roundtripEqual (x::Meta)) + + , testProperty "documents can be round-tripped through the lua stack" $ + \x -> ioProperty (roundtripEqual (x::Pandoc)) + + , testCase "macro expansion via filter" $ assertFilterConversion "a '{{helloworld}}' string is expanded" "strmacro.lua" (doc . para $ str "{{helloworld}}") @@ -40,17 +53,11 @@ tests = (doc $ rawBlock "markdown" "*charly* **delta**") (doc . para $ emph "charly" <> space <> strong "delta") - , testProperty "inline elements can be round-tripped through the lua stack" $ - \x -> ioProperty (roundtripEqual (x::Inline)) - - , testProperty "block elements can be round-tripped through the lua stack" $ - \x -> ioProperty (roundtripEqual (x::Block)) - - , testProperty "meta blocks can be round-tripped through the lua stack" $ - \x -> ioProperty (roundtripEqual (x::Meta)) - - , testProperty "documents can be round-tripped through the lua stack" $ - \x -> ioProperty (roundtripEqual (x::Pandoc)) + , 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") ] assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion diff --git a/test/lua/single-to-double-quoted.lua b/test/lua/single-to-double-quoted.lua new file mode 100644 index 000000000..8a0a5732a --- /dev/null +++ b/test/lua/single-to-double-quoted.lua @@ -0,0 +1,7 @@ +return { + { + SingleQuoted = function (content) + return pandoc.Quoted("DoubleQuote", content) + end, + } +} |