diff options
| author | Albert Krewinkel <[email protected]> | 2025-07-21 10:40:24 +0200 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2025-07-21 11:11:25 +0200 |
| commit | f596612abd69c4aa517cc59df69ef6c4707f14bc (patch) | |
| tree | 4a2bcc33f46f3a228e01db5f1340ebd53cb8fbe6 | |
| parent | 20950fdfaba7b532a9dfc354f46c8b237495a615 (diff) | |
Typst: add support for custom and/or translated "Abstract" titles
Closes: #9724
| -rw-r--r-- | data/templates/template.typst | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Typst.hs | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/data/templates/template.typst b/data/templates/template.typst index 1889bef6f..24b1320fb 100644 --- a/data/templates/template.typst +++ b/data/templates/template.typst @@ -80,7 +80,7 @@ #if abstract != none { block(inset: 2em)[ - #text(weight: "semibold")[Abstract] #h(1em) #abstract + #text(weight: "semibold")[$if(abstract-title)$${abstract-title}$else$Abstract$endif$] #h(1em) #abstract ] } ] diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs index 90409cbbf..9e71ea513 100644 --- a/src/Text/Pandoc/Writers/Typst.hs +++ b/src/Text/Pandoc/Writers/Typst.hs @@ -29,8 +29,9 @@ import Network.URI (unEscapeString) import qualified Data.Text as T import Control.Monad.State ( StateT, evalStateT, gets, modify ) import Text.Pandoc.Writers.Shared ( metaToContext, defField, resetField, - lookupMetaString ) + setupTranslations, lookupMetaString ) import Text.Pandoc.Shared (isTightList, orderedListMarkers, tshow) +import Text.Pandoc.Translations (Term(Abstract), translateTerm) import Text.Pandoc.Writers.Math (convertMath) import qualified Text.TeXMath as TM import Text.DocLayout @@ -64,11 +65,13 @@ pandocToTypst options (Pandoc meta blocks) = do let colwidth = if writerWrapText options == WrapAuto then Just $ writerColumns options else Nothing + setupTranslations meta metadata <- metaToContext options blocksToTypst (fmap chomp . inlinesToTypst) meta main <- blocksToTypst blocks + abstractTitle <- translateTerm Abstract let toPosition :: CaptionPosition -> Text toPosition CaptionAbove = "top" toPosition CaptionBelow = "bottom" @@ -87,6 +90,7 @@ pandocToTypst options (Pandoc meta blocks) = do maybe id (resetField "region") (langRegion l)) $ defField "csl" (lookupMetaString "citation-style" meta) -- #10661 $ defField "smart" (isEnabled Ext_smart options) + $ defField "abstract-title" abstractTitle $ defField "toc-depth" (tshow $ writerTOCDepth options) $ defField "figure-caption-position" (toPosition $ writerFigureCaptionPosition options) |
