aboutsummaryrefslogtreecommitdiffstats
path: root/app/Render.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Render.hs')
-rw-r--r--app/Render.hs19
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)