renderInline :: Inline -> Builder
renderInline el = case el of
    LineBreak -> "\n"
    Space -> " "
    SoftBreak -> " "
    Entity t -> fromText t
    RawHtml t -> fromText t
    (Str s) -> fromText s
    (Link els url _) ->
        "[" <>
        renderInlinesWith [ SetConsoleIntensity BoldIntensity ] els <>
        setSGRCodeBuilder [ Reset ] <>
        "](" <>
        setSGRCodeBuilder [ SetColor Foreground Vivid Blue ] <>
        fromText url <>
        setSGRCodeBuilder [ Reset ] <>
        ")"
    (Emph els) ->
        renderInlinesWith [ SetItalicized True
                               , SetUnderlining SingleUnderline
                               ] els <>
        setSGRCodeBuilder [ Reset ]
    (Strong els) ->
        renderInlinesWith [ SetConsoleIntensity BoldIntensity ] els <>
        setSGRCodeBuilder [ Reset ]
    (Code s) ->
        setSGRCodeBuilder [ SetColor Foreground Dull Yellow ] <>
        fromText s <>
        setSGRCodeBuilder [ Reset ]
    (Image _ url tit) ->
        "![" <>
        setSGRCodeBuilder [ SetConsoleIntensity BoldIntensity ] <>
        fromText tit <>
        setSGRCodeBuilder [ Reset ] <>
        "](" <>
        setSGRCodeBuilder [ SetColor Foreground Vivid Blue ] <>
        fromText url <>
        setSGRCodeBuilder [ Reset ] <>
        ")"
  where
    renderInlinesWith sgr = mconcatMapF helper
      where
        helper e = setSGRCodeBuilder sgr <> renderInline e
renderInline :: Inline -> Builder
renderInline el = case el of
    LineBreak -> "\n"
    Space -> " "
    SoftBreak -> " "
    Entity t -> fromText t
    RawHtml t -> fromText t
    (Str s) -> fromText s
    (Link els url _) ->
        "[" <>
        renderInlinesWith [ SetConsoleIntensity BoldIntensity ] els <>
        setSGRCodeBuilder [ Reset ] <>
        "](" <>
        setSGRCodeBuilder [ SetColor Foreground Vivid Blue ] <>
        fromText url <>
        setSGRCodeBuilder [ Reset ] <>
        ")"
    (Emph els) ->
        renderInlinesWith [ SetItalicized True
                               , SetUnderlining SingleUnderline
                               ] els <>
        setSGRCodeBuilder [ Reset ]
    (Strong els) ->
        renderInlinesWith [ SetConsoleIntensity BoldIntensity ] els <>
        setSGRCodeBuilder [ Reset ]
    (Code s) ->
        setSGRCodeBuilder [ SetColor Foreground Dull Yellow ] <>
        fromText s <>
        setSGRCodeBuilder [ Reset ]
    (Image _ url tit) ->
        "![" <>
        setSGRCodeBuilder [ SetConsoleIntensity BoldIntensity ] <>
        fromText tit <>
        setSGRCodeBuilder [ Reset ] <>
        "](" <>
        setSGRCodeBuilder [ SetColor Foreground Vivid Blue ] <>
        fromText url <>
        setSGRCodeBuilder [ Reset ] <>
        ")"
  where
    renderInlinesWith sgr = mconcatMapF helper
      where
        helper e = setSGRCodeBuilder sgr <> renderInline e
renderInline el = case el of
    LineBreak -> "\n"
    Space -> " "
    SoftBreak -> " "
    Entity t -> fromText t
    RawHtml t -> fromText t
    (Str s) -> fromText s
    (Link els url _) ->
        "[" <>
        renderInlinesWith [ SetConsoleIntensity BoldIntensity ] els <>
        setSGRCodeBuilder [ Reset ] <>
        "](" <>
        setSGRCodeBuilder [ SetColor Foreground Vivid Blue ] <>
        fromText url <>
        setSGRCodeBuilder [ Reset ] <>
        ")"
    (Emph els) ->
        renderInlinesWith [ SetItalicized True
                               , SetUnderlining SingleUnderline
                               ] els <>
        setSGRCodeBuilder [ Reset ]
    (Strong els) ->
        renderInlinesWith [ SetConsoleIntensity BoldIntensity ] els <>
        setSGRCodeBuilder [ Reset ]
    (Code s) ->
        setSGRCodeBuilder [ SetColor Foreground Dull Yellow ] <>
        fromText s <>
        setSGRCodeBuilder [ Reset ]
    (Image _ url tit) ->
        "![" <>
        setSGRCodeBuilder [ SetConsoleIntensity BoldIntensity ] <>
        fromText tit <>
        setSGRCodeBuilder [ Reset ] <>
        "](" <>
        setSGRCodeBuilder [ SetColor Foreground Vivid Blue ] <>
        fromText url <>
        setSGRCodeBuilder [ Reset ] <>
        ")"
  where
    renderInlinesWith sgr = mconcatMapF helper
      where
        helper e = setSGRCodeBuilder sgr <> renderInline e