summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/HTML.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 358017fd4..9581702a7 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -102,17 +102,19 @@ nl opts = if writerWrapText opts == WrapNone
writeHtmlString :: WriterOptions -> Pandoc -> String
writeHtmlString opts d =
let (body, context) = evalState (pandocToHtml opts d) defaultWriterState
- in if writerStandalone opts
- then inTemplate opts context body
- else renderHtml body
+ in case writerTemplate opts of
+ Nothing -> renderHtml body
+ Just tpl -> renderTemplate' tpl $
+ defField "body" (renderHtml body) context
-- | Convert Pandoc document to Html structure.
writeHtml :: WriterOptions -> Pandoc -> Html
writeHtml opts d =
let (body, context) = evalState (pandocToHtml opts d) defaultWriterState
- in if writerStandalone opts
- then inTemplate opts context body
- else body
+ in case writerTemplate opts of
+ Nothing -> body
+ Just tpl -> renderTemplate' tpl $
+ defField "body" (renderHtml body) context
-- result is (title, authors, date, toc, body, new variables)
pandocToHtml :: WriterOptions
@@ -194,14 +196,6 @@ pandocToHtml opts (Pandoc meta blocks) = do
metadata
return (thebody, context)
-inTemplate :: TemplateTarget a
- => WriterOptions
- -> Value
- -> Html
- -> a
-inTemplate opts context body = renderTemplate' (writerTemplate opts)
- $ defField "body" (renderHtml body) context
-
-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
prefixedId :: WriterOptions -> String -> Attribute
prefixedId opts s =