Skip to content

Commit

Permalink
Revamp display of headings
Browse files Browse the repository at this point in the history
All headings at the document top-level are green. Headings inner to
structures like blockquotes and lists are not. H1 is bold and all caps.
H2 is bold. H3-H6 are italic. The design here is meant to be relatively
boring/simple and allow telling H1 and H2 apart from each other and from
the remaining heading levels.
  • Loading branch information
silby committed Apr 4, 2024
1 parent 8a0e361 commit 016b1b0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Text/Pandoc/Writers/ANSI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ blockToANSI _ HorizontalRule = return $ D.blankline $$ hr $$ D.blankline
blockToANSI opts (Header level _ inlines) = do
contents <- inlineListToANSI opts inlines
inner <- gets stInner
return $ header inner level contents $$ D.blankline where
header False 1 = (D.flush . D.bold)
header True 1 = (D.underlined . D.bold)
header False 2 = ((<> D.literal " ") . D.bold)
header True 2 = D.bold
header _ 3 = D.italic
header _ _ = id
return $ color inner (header level contents) $$ D.blankline where
header 1 d = fmap T.toUpper (D.bold d)
header 2 d = D.bold d
header _ d = D.italic d
color False = D.fg D.green
color True = id

-- The approach to code blocks and highlighting here is a best-effort with
-- existing tools, and can easily produce results that aren't quite right. Using
Expand Down

0 comments on commit 016b1b0

Please sign in to comment.