From c5c7022ac537ff98f625432fe70bcd5b491d1d96 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 18 Mar 2024 10:13:51 -0700 Subject: Typst writer: handle `unnumbered` on headings. Closes #9585. --- src/Text/Pandoc/Writers/Typst.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs index 7d061ed05..976980d20 100644 --- a/src/Text/Pandoc/Writers/Typst.hs +++ b/src/Text/Pandoc/Writers/Typst.hs @@ -97,13 +97,18 @@ blockToTypst block = Header level (ident,cls,_) inlines -> do contents <- inlinesToTypst inlines let lab = toLabel FreestandingLabel ident + let headingAttrs = + ["outlined: false" | "unlisted" `elem` cls] ++ + ["numbering: none" | "unnumbered" `elem` cls] return $ - if "unlisted" `elem` cls - then literal "#heading(outlined: false)" <> brackets contents <> - cr <> lab - else nowrap + if null headingAttrs + then nowrap (literal (T.replicate level "=") <> space <> contents) <> cr <> lab + else literal "#heading" <> + parens (literal (T.intercalate ", " + ("level: " <> tshow level : headingAttrs))) <> + brackets contents <> cr <> lab RawBlock fmt str -> case fmt of Format "typst" -> return $ literal str -- cgit v1.2.3