pandoc

What is the practical difference between `writeHtml5` and `writeHtml5string`?


It seems that the writeHtml5 produces a structure, which can be rendered with Blaze. writeHtml5string produces Text. I looked at the code but cannot understand if there is a difference to call writeHtml5string or combine writeHtml5 and renderHtml from Blaze. Are there cases where one or the other is advisable? Is the option with Blaze faster?


Solution

  • writeHtml5string is the function pandoc uses itself for the cli, so if you need a Text in the end, that's what I'd use. It calls renderHtml', which is implemented as:

    import Text.Blaze.Html.Renderer.Text (renderHtml)
    import qualified Data.Text.Lazy as TL
    
    renderHtml' :: Html -> Text
    renderHtml' = TL.toStrict . renderHtml
    

    If you want to add the HTML snippet to another Blaze document, then you should use writeHtml5 instead.