diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-03-18 10:13:51 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-03-18 10:13:51 -0700 |
| commit | c5c7022ac537ff98f625432fe70bcd5b491d1d96 (patch) | |
| tree | 2e870a103c9217f6d413d8bdc7ea15433f9474c6 /src/Text/Pandoc | |
| parent | 602cf00dfcec10ddfad38beedcf1bd542fc1a688 (diff) | |
Typst writer: handle `unnumbered` on headings.
Closes #9585.
Diffstat (limited to 'src/Text/Pandoc')
| -rw-r--r-- | src/Text/Pandoc/Writers/Typst.hs | 13 |
1 files changed, 9 insertions, 4 deletions
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 |
