diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-12-05 10:11:54 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-12-05 14:55:59 +0100 |
commit | 23bacb83e6ea67ffdd62be630626ab50ff665abf (patch) | |
tree | fcb7691e3f8862400c00f0ca823503e5087f411e /app/Render.hs | |
parent | 1b1c3faabae530229eb675a2e70e744c2f45cbbe (diff) |
feat: parse issues as markdown
Diffstat (limited to 'app/Render.hs')
-rw-r--r-- | app/Render.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/app/Render.hs b/app/Render.hs index 2220fb8..f63a3bc 100644 --- a/app/Render.hs +++ b/app/Render.hs @@ -28,7 +28,7 @@ module Render where import CMark qualified as D -import Data.List (isPrefixOf, isSuffixOf, intersperse) +import Data.List (intersperse, isPrefixOf, isSuffixOf) import Data.Maybe (catMaybes) import Data.Text qualified as T import Data.Time.Calendar (Day) @@ -94,7 +94,22 @@ renderAsMarkdown :: T.Text -> Doc AnsiStyle renderAsMarkdown = render . Markdown . D.commonmarkToNode [] instance Render Markdown where - render = maybe emptyDoc go . rec . unMarkdown + render = render . unMarkdown + +instance Render [D.Node] where + render = render . D.Node Nothing D.DOCUMENT + +-- TODO Fix spacing between markdown nodes +-- +-- The following code suffers from the problem that inline code such as `foo` is not separated correctly when surrounded by non-whitespace characters, ie. `foo`, or `foo`s. +-- +-- The reason for that is that we generally trim words within `TEXT` nodes, and then add the spaces back. +-- +-- Thus, we should not trim words. But we should still replace whitespace by `P.softline`s (ie. `P.fillSep`) for automatic paragraph wrapping. +-- +-- @topic markdown +instance Render D.Node where + render = maybe emptyDoc go . rec where rec (D.Node _ D.SOFTBREAK _) = Nothing rec (D.Node p t ns) = Just $ D.Node p t (catMaybes $ map rec ns) |