Skip to content

Commit 016b1b0

Browse files
committed
Revamp display of headings
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.
1 parent 8a0e361 commit 016b1b0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Text/Pandoc/Writers/ANSI.hs

+6-7
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,12 @@ blockToANSI _ HorizontalRule = return $ D.blankline $$ hr $$ D.blankline
129129
blockToANSI opts (Header level _ inlines) = do
130130
contents <- inlineListToANSI opts inlines
131131
inner <- gets stInner
132-
return $ header inner level contents $$ D.blankline where
133-
header False 1 = (D.flush . D.bold)
134-
header True 1 = (D.underlined . D.bold)
135-
header False 2 = ((<> D.literal " ") . D.bold)
136-
header True 2 = D.bold
137-
header _ 3 = D.italic
138-
header _ _ = id
132+
return $ color inner (header level contents) $$ D.blankline where
133+
header 1 d = fmap T.toUpper (D.bold d)
134+
header 2 d = D.bold d
135+
header _ d = D.italic d
136+
color False = D.fg D.green
137+
color True = id
139138

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

0 commit comments

Comments
 (0)