From ae21a8bb2a9d892491424f257ed0146c1b2affa2 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 30 Apr 2017 16:14:33 +0200 Subject: Lua filter: fall-back to global filters when none is returned The implicitly defined global filter (i.e. all element filtering functions defined in the global lua environment) is used if no filter is returned from a lua script. This allows to just write top-level functions in order to define a lua filter. E.g function Emph(elem) return pandoc.Strong(elem.content) end --- test/Tests/Lua.hs | 6 ++++++ test/lua/implicit-doc-filter.lua | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 test/lua/implicit-doc-filter.lua (limited to 'test') diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 80c733751..50f9634a2 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -47,6 +47,12 @@ tests = (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" diff --git a/test/lua/implicit-doc-filter.lua b/test/lua/implicit-doc-filter.lua new file mode 100644 index 000000000..320d22105 --- /dev/null +++ b/test/lua/implicit-doc-filter.lua @@ -0,0 +1,6 @@ +function Doc (doc) + local meta = {} + local hello = { pandoc.Str "Hello,", pandoc.Space(), pandoc.Str "World!" } + local blocks = { pandoc.Para(hello) } + return pandoc.Doc(blocks, meta) +end -- cgit v1.2.3