diff options
| author | John MacFarlane <[email protected]> | 2023-06-05 16:07:36 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2023-06-05 16:07:36 -0700 |
| commit | 2c8de4c12939d8f9c0df0950e1f16fdccb1d86e6 (patch) | |
| tree | 0e1e22d4ddf71cb01574ec8cff697606198427dd /src | |
| parent | 5539eecd0bac048494a551b3da17f33d9b11c069 (diff) | |
Typst writer: use `#footnote` for notes.
Closes #8893.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/Typst.hs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs index a3267f911..091911518 100644 --- a/src/Text/Pandoc/Writers/Typst.hs +++ b/src/Text/Pandoc/Writers/Typst.hs @@ -43,8 +43,7 @@ writeTypst :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeTypst options document = evalStateT (pandocToTypst options document) WriterState{ stOptions = options, - stEscapeContext = NormalContext, - stNotes = [] } + stEscapeContext = NormalContext } data EscapeContext = NormalContext | TermContext deriving (Show, Eq) @@ -52,9 +51,7 @@ data EscapeContext = NormalContext | TermContext data WriterState = WriterState { stOptions :: WriterOptions, - stEscapeContext :: EscapeContext, - stNotes :: [Doc Text] - } + stEscapeContext :: EscapeContext } type TW m = StateT WriterState m @@ -69,14 +66,7 @@ pandocToTypst options (Pandoc meta blocks) = do (fmap chomp . inlinesToTypst) meta main <- blocksToTypst blocks - noteContents <- reverse <$> gets stNotes - let notes = vsep $ zipWith - (\(num :: Int) cont -> - "#endnote" <> parens (brackets (text (show num)) - <> ", " <> brackets (chomp cont <> cr))) - [1..] noteContents let context = defField "body" main - $ defField "notes" notes $ defField "toc" (writerTableOfContents options) $ (if isEnabled Ext_citations options then defField "citations" True @@ -291,12 +281,9 @@ inlineToTypst inline = let height' = maybe mempty ((", height: " <>) . literal) $ lookup "height" kvs return $ "#image(" <> doubleQuoted src <> width' <> height' <> ")" - Note blocks -> do -- currently typst has no footnotes! - -- TODO create endnotes with manual typesetting + Note blocks -> do contents <- blocksToTypst blocks - modify $ \st -> st{ stNotes = contents : stNotes st } - num <- text . show . length <$> gets stNotes - return $ "#super" <> brackets num + return $ "#footnote" <> brackets (chomp contents) textstyle :: PandocMonad m => Doc Text -> [Inline] -> TW m (Doc Text) textstyle s inlines = (s <>) . brackets <$> inlinesToTypst inlines |
