@@ -51,12 +51,18 @@ defaultWriterState :: WriterState
5151defaultWriterState = WriterState {stNotes= [], stIds = [],
5252 stMath = False, stCSS = S.empty}
5353
54+-- Helpers to render HTML with the appropriate function.
55+render opts = if writerWrapText opts then renderHtml else showHtml
56+renderFragment opts = if writerWrapText opts
57+ then renderHtmlFragment
58+ else showHtmlFragment
59+
5460-- | Convert Pandoc document to Html string.
5561writeHtmlString :: WriterOptions -> Pandoc -> String
5662writeHtmlString opts =
5763 if writerStandalone opts
58− then renderHtml . writeHtml opts
59− else renderHtmlFragment . writeHtml opts
64+ then render opts . writeHtml opts
65+ else renderFragment opts . writeHtml opts
6066
6167-- | Convert Pandoc document to Html structure.
6268writeHtml :: WriterOptions -> Pandoc -> Html
@@ -406,7 +412,7 @@ inlineToHtml opts inline =
406412 linkText
407413 (Image txt (source,tit)) -> do
408414 alternate <- inlineListToHtml opts txt
409− let alternate' = renderHtmlFragment alternate
415+ let alternate' = renderFragment opts alternate
410416 let attributes = [src source] ++
411417 (if null tit
412418 then []