diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-07-26 12:00:44 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-07-28 19:25:45 -0700 |
commit | b35fae651145482f1218d32dbea5fffff60e0b0b (patch) | |
tree | 02175f056c40aee4329b8f944ada9c9cd6ac1284 /src/Text/Pandoc/Writers/Custom.hs | |
parent | 99e24cf18337b0b460005bf77e367783c34b75e7 (diff) | |
download | pandoc-b35fae651145482f1218d32dbea5fffff60e0b0b.tar.gz |
Use doctemplates 0.3, change type of writerTemplate.
* Require recent doctemplates. It is more flexible and
supports partials.
* Changed type of writerTemplate to Maybe Template instead
of Maybe String.
* Remove code from the LaTeX, Docbook, and JATS writers that looked in
the template for strings to determine whether it is a book or an
article, or whether csquotes is used. This was always kludgy and
unreliable. To use csquotes for LaTeX, set `csquotes` in your
variables or metadata. It is no longer sufficient to put
`\usepackage{csquotes}` in your template or header includes.
To specify a book style, use the `documentclass` variable or
`--top-level-division`.
* Change template code to use new API for doctemplates.
Diffstat (limited to 'src/Text/Pandoc/Writers/Custom.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Custom.hs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 5e2f3a583..7d85a262d 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -25,7 +25,6 @@ import Data.Typeable import Foreign.Lua (Lua, Pushable) import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition -import Text.Pandoc.Error import Text.Pandoc.Lua (Global (..), LuaException (LuaException), runLua, setGlobals) import Text.Pandoc.Lua.Util (addField, dofileWithTraceback) @@ -109,12 +108,10 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do let (body, context) = case res of Left (LuaException msg) -> throw (PandocLuaException msg) Right x -> x - case writerTemplate opts of - Nothing -> return $ pack body - Just tpl -> - case applyTemplate (pack tpl) $ setField "body" body context of - Left e -> throw (PandocTemplateError e) - Right r -> return r + return $ + case writerTemplate opts of + Nothing -> pack body + Just tpl -> renderTemplate tpl $ setField "body" body context docToCustom :: WriterOptions -> Pandoc -> Lua String docToCustom opts (Pandoc (Meta metamap) blocks) = do |