aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-10-20 22:49:04 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-10-29 22:21:35 -0700
commit1fe97422630d4aa5644d55b0b3b41b0978b7fea0 (patch)
tree32477f9869a265d9a275651b2715b5991c6cbb4c /src/Text/Pandoc/Lua
parent4d5fd9e2fe360e47fd5beab724c612ce29aa39ee (diff)
downloadpandoc-1fe97422630d4aa5644d55b0b3b41b0978b7fea0.tar.gz
Changes to build with new doctemplates/doclayout.
The new version of doctemplates adds many features to pandoc's templating system, while remaining backwards-compatible. New features include partials and filters. Using template filters, one can lay out data in enumerated lists and tables. Templates are now layout-sensitive: so, for example, if a text with soft line breaks is interpolated near the end of a line, the text will break and wrap naturally. This makes the templating system much more suitable for programatically generating markdown or other plain-text files from metadata.
Diffstat (limited to 'src/Text/Pandoc/Lua')
-rw-r--r--src/Text/Pandoc/Lua/Marshaling/Context.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling/Context.hs b/src/Text/Pandoc/Lua/Marshaling/Context.hs
index a9cc7f38e..e209fbd61 100644
--- a/src/Text/Pandoc/Lua/Marshaling/Context.hs
+++ b/src/Text/Pandoc/Lua/Marshaling/Context.hs
@@ -16,16 +16,18 @@ Marshaling instance for doctemplates Context and its components.
-}
module Text.Pandoc.Lua.Marshaling.Context () where
+import Prelude
import qualified Foreign.Lua as Lua
import Foreign.Lua (Pushable)
-import Text.DocTemplates (Context(..), Val(..))
+import Text.DocTemplates (Context(..), Val(..), TemplateTarget)
+import Text.DocLayout (render)
-instance Pushable a => Pushable (Context a) where
+instance (TemplateTarget a, Pushable a) => Pushable (Context a) where
push (Context m) = Lua.push m
-instance Pushable a => Pushable (Val a) where
+instance (TemplateTarget a, Pushable a) => Pushable (Val a) where
push NullVal = Lua.push ()
push (MapVal ctx) = Lua.push ctx
push (ListVal xs) = Lua.push xs
- push (SimpleVal x) = Lua.push x
+ push (SimpleVal d) = Lua.push $ render Nothing d