diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-10-20 22:49:04 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-10-29 22:21:35 -0700 |
commit | 1fe97422630d4aa5644d55b0b3b41b0978b7fea0 (patch) | |
tree | 32477f9869a265d9a275651b2715b5991c6cbb4c /src/Text/Pandoc/Writers/CommonMark.hs | |
parent | 4d5fd9e2fe360e47fd5beab724c612ce29aa39ee (diff) | |
download | pandoc-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/Writers/CommonMark.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/CommonMark.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs index a572123fc..8e6e8af51 100644 --- a/src/Text/Pandoc/Writers/CommonMark.hs +++ b/src/Text/Pandoc/Writers/CommonMark.hs @@ -34,6 +34,7 @@ import Text.Pandoc.Walk (walk, walkM) import Text.Pandoc.Writers.HTML (writeHtml5String, tagWithAttributes) import Text.Pandoc.Writers.Shared import Text.Pandoc.XML (toHtml5Entities) +import Text.DocLayout (literal, render) -- | Convert Pandoc to CommonMark. writeCommonMark :: PandocMonad m => WriterOptions -> Pandoc -> m Text @@ -50,8 +51,8 @@ writeCommonMark opts (Pandoc meta blocks) = do else [OrderedList (1, Decimal, Period) $ reverse notes] main <- blocksToCommonMark opts (blocks' ++ notes') metadata <- metaToContext opts - (fmap T.stripEnd . blocksToCommonMark opts) - (fmap T.stripEnd . inlinesToCommonMark opts) + (fmap (literal . T.stripEnd) . blocksToCommonMark opts) + (fmap (literal . T.stripEnd) . inlinesToCommonMark opts) meta let context = -- for backwards compatibility we populate toc @@ -62,7 +63,7 @@ writeCommonMark opts (Pandoc meta blocks) = do return $ case writerTemplate opts of Nothing -> main - Just tpl -> renderTemplate tpl context + Just tpl -> render Nothing $ renderTemplate tpl context softBreakToSpace :: Inline -> Inline softBreakToSpace SoftBreak = Space |