aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue/Render.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-05 10:11:54 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-05 14:55:59 +0100
commit23bacb83e6ea67ffdd62be630626ab50ff665abf (patch)
treefcb7691e3f8862400c00f0ca823503e5087f411e /app/Issue/Render.hs
parent1b1c3faabae530229eb675a2e70e744c2f45cbbe (diff)
feat: parse issues as markdown
Diffstat (limited to 'app/Issue/Render.hs')
-rw-r--r--app/Issue/Render.hs29
1 files changed, 27 insertions, 2 deletions
diff --git a/app/Issue/Render.hs b/app/Issue/Render.hs
index ea504d5..ed40ed7 100644
--- a/app/Issue/Render.hs
+++ b/app/Issue/Render.hs
@@ -4,12 +4,14 @@ module Issue.Render
( IssueTitle (..),
IssueDescription (..),
IssueTags (..),
+ IssueComments (..),
IssueOpenedOn (..),
IssueOpenedBy (..),
)
where
import Data.List (intersperse)
+import Data.List.NonEmpty qualified as N
import Data.Map qualified as M
import Data.Text qualified as T
import Data.Time.Clock (UTCTime (utctDay))
@@ -18,8 +20,22 @@ import Issue.Provenance (Author (..), Commit (..), Provenance (..))
import Render ((<<<))
import Render qualified as P
+-- TODO Easily separate renderables by newlines
+--
+-- For convenience, the (<<<) combinator adds spaces between renderable entities, **if** those renderables are non-empty.
+--
+-- We should similarly allow for a combinator that similarly adds empty lines between renderable entities.
+--
+-- @topic rendering
instance P.Render (P.Detailed Issue) where
- render (P.Detailed issue) = P.renderAsMarkdown issue.rawText
+ render (P.Detailed issue) =
+ IssueTitle issue
+ <<< P.hardline @P.AnsiStyle
+ <<< IssueDescription issue
+ <<< P.hardline @P.AnsiStyle
+ <<< IssueTags issue
+ <<< P.hardline @P.AnsiStyle
+ <<< IssueComments issue
instance P.Render Issue where
render = P.render . P.Detailed
@@ -34,7 +50,9 @@ instance P.Render IssueTitle where
newtype IssueDescription = IssueDescription {unIssueDescription :: Issue}
instance P.Render IssueDescription where
- render (IssueDescription issue) = maybe P.emptyDoc P.pretty issue.description
+ render (IssueDescription issue) =
+ maybe P.emptyDoc (P.render . N.toList) $
+ issue.description
instance P.Render (P.Linked Issue) where
render (P.Linked issue)
@@ -58,6 +76,13 @@ newtype IssueTags = IssueTags {unIssueTags :: Issue}
instance P.Render IssueTags where
render (IssueTags issue) = P.render issue.tags
+newtype IssueComments = IssueComments {unIssueComments :: Issue}
+
+instance P.Render IssueComments where
+ render (IssueComments issue) =
+ maybe P.emptyDoc (P.vsep . map P.render . N.toList) $
+ issue.comments
+
newtype IssueOpenedBy = IssueOpenedBy {unIssueOpenedBy :: Issue}
instance P.Render IssueOpenedBy where