@@ -102,17 +102,19 @@ nl opts = if writerWrapText opts == WrapNone
102writeHtmlString :: WriterOptions -> Pandoc -> String
102writeHtmlString :: WriterOptions -> Pandoc -> String
103writeHtmlString opts d =
103writeHtmlString opts d =
104 let (body, context) = evalState (pandocToHtml opts d) defaultWriterState
104 let (body, context) = evalState (pandocToHtml opts d) defaultWriterState
105− in if writerStandalone opts
105+ in case writerTemplate opts of
106− then inTemplate opts context body
106+ Nothing -> renderHtml body
107− else renderHtml body
107+ Just tpl -> renderTemplate' tpl $
108+ defField "body" (renderHtml body) context
109-- | Convert Pandoc document to Html structure.
110-- | Convert Pandoc document to Html structure.
110writeHtml :: WriterOptions -> Pandoc -> Html
111writeHtml :: WriterOptions -> Pandoc -> Html
111writeHtml opts d =
112writeHtml opts d =
112 let (body, context) = evalState (pandocToHtml opts d) defaultWriterState
113 let (body, context) = evalState (pandocToHtml opts d) defaultWriterState
113− in if writerStandalone opts
114+ in case writerTemplate opts of
114− then inTemplate opts context body
115+ Nothing -> body
115− else body
116+ Just tpl -> renderTemplate' tpl $
117+ defField "body" (renderHtml body) context
117-- result is (title, authors, date, toc, body, new variables)
119-- result is (title, authors, date, toc, body, new variables)
118pandocToHtml :: WriterOptions
120pandocToHtml :: WriterOptions
@@ -194,14 +196,6 @@ pandocToHtml opts (Pandoc meta blocks) = do
195 return (thebody, context)
197 return (thebody, context)
197−inTemplate :: TemplateTarget a
202−inTemplate opts context body = renderTemplate' (writerTemplate opts)
203− $ defField "body" (renderHtml body) context
205-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
199-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
206prefixedId :: WriterOptions -> String -> Attribute
200prefixedId :: WriterOptions -> String -> Attribute
207prefixedId opts s =
201prefixedId opts s =