diff options
| -rw-r--r-- | data/templates/default.typst | 5 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Typst.hs | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/data/templates/default.typst b/data/templates/default.typst index 00e1ec557..4c75fd0f4 100644 --- a/data/templates/default.typst +++ b/data/templates/default.typst @@ -132,6 +132,9 @@ $endif$ $body$ $if(citations)$ +$for(nocite-ids)$ +#cite(label("${it}"), form: none) +$endfor$ $if(csl)$ #set bibliography(style: "$csl$") @@ -141,7 +144,7 @@ $elseif(bibliographystyle)$ $endif$ $if(bibliography)$ -#bibliography($for(bibliography)$"$bibliography$"$sep$,$endfor$) +#bibliography($for(bibliography)$"$bibliography$"$sep$,$endfor$$if(full-bibliography)$, full: true$endif$) $endif$ $endif$ $for(include-after)$ diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs index 9e71ea513..7fd7e1cf6 100644 --- a/src/Text/Pandoc/Writers/Typst.hs +++ b/src/Text/Pandoc/Writers/Typst.hs @@ -28,10 +28,12 @@ import Data.Bifunctor (first, second) 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, - setupTranslations, lookupMetaString ) +import Text.Pandoc.Writers.Shared ( lookupMetaInlines, lookupMetaString, + metaToContext, defField, resetField, + setupTranslations ) import Text.Pandoc.Shared (isTightList, orderedListMarkers, tshow) import Text.Pandoc.Translations (Term(Abstract), translateTerm) +import Text.Pandoc.Walk (query) import Text.Pandoc.Writers.Math (convertMath) import qualified Text.TeXMath as TM import Text.DocLayout @@ -75,10 +77,17 @@ pandocToTypst options (Pandoc meta blocks) = do let toPosition :: CaptionPosition -> Text toPosition CaptionAbove = "top" toPosition CaptionBelow = "bottom" + let nociteIds = query (\inln -> case inln of + Cite cs _ -> map citationId cs + _ -> []) + $ lookupMetaInlines "nocite" meta + let context = defField "body" main $ defField "toc" (writerTableOfContents options) $ (if isEnabled Ext_citations options then defField "citations" True + . defField "nocite-ids" (filter (/= "*") nociteIds) + . defField "full-bibliography" ("*" `elem` nociteIds) else id) $ (case lookupMetaString "lang" meta of "" -> id |
