diff options
| author | John MacFarlane <[email protected]> | 2025-03-05 13:24:05 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-03-05 13:24:05 -0800 |
| commit | e73b9ee1d80b0732d2e422b3ab30260b646e47a2 (patch) | |
| tree | 14412825be46f92bd34f133cd8952704e9aff199 | |
| parent | b58381a0d498a3c6a1e45f69807366e8674448d7 (diff) | |
Disable citations extension in writers if `--citeproc` is used.
Otherwise we get undesirable results, as the format's native
citation mechanism is used instead of (or in addition to) the
citeproc-generated citations. Closes #10662.
| -rw-r--r-- | MANUAL.txt | 9 | ||||
| -rw-r--r-- | src/Text/Pandoc/App/OutputSettings.hs | 7 | ||||
| -rw-r--r-- | src/Text/Pandoc/Filter.hs | 2 | ||||
| -rw-r--r-- | test/command/7329.md | 7 |
4 files changed, 17 insertions, 8 deletions
diff --git a/MANUAL.txt b/MANUAL.txt index ca3126171..d57682318 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -1505,11 +1505,10 @@ header when requesting a document from a URL: order they appear on the command line. For more information, see the section on [Citations]. - Note: if your target format is `markdown`, `org`, or `typst`, - you will need to disable the `citations` extension (e.g., `-t - markdown-citations`) to see the rendered citations and - bibliography. Otherwise the format's own citation syntax will - be used. + Note: if this option is specified, the `citations` extension + will be disabled automatically in the writer, to ensure that + the citeproc-generated citations will be rendered instead of + the format's own citation syntax. `--bibliography=`*FILE* diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 38cd35455..3824ecbda 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -38,6 +38,7 @@ import System.FilePath import System.IO (stdout) import Text.Pandoc.Chunks (PathTemplate(..)) import Text.Pandoc +import Text.Pandoc.Filter (Filter(CiteprocFilter)) import Text.Pandoc.App.Opt (Opt (..)) import Text.Pandoc.App.CommandLineOptions (engines) import Text.Pandoc.Format (FlavoredFormat (..), applyExtensionsDiff, @@ -121,7 +122,7 @@ optToOutputSettings scriptingEngine opts = do then getAndCompile (tp <.> T.unpack format) else throwError e) - (writer, writerExts, mtemplate) <- + (writer, writerExts', mtemplate) <- if "lua" `T.isSuffixOf` format then do let path = T.unpack format @@ -150,6 +151,10 @@ optToOutputSettings scriptingEngine opts = do tmpl <- processCustomTemplate (compileDefaultTemplate format) return (w, wexts, tmpl) + -- see #10662: + let writerExts = if CiteprocFilter `elem` optFilters opts + then disableExtension Ext_citations writerExts' + else writerExts' let addSyntaxMap existingmap f = do res <- liftIO (parseSyntaxDefinition f) diff --git a/src/Text/Pandoc/Filter.hs b/src/Text/Pandoc/Filter.hs index 7b51f7239..36700d5f6 100644 --- a/src/Text/Pandoc/Filter.hs +++ b/src/Text/Pandoc/Filter.hs @@ -41,7 +41,7 @@ import Control.Monad (foldM, when) data Filter = LuaFilter FilePath | JSONFilter FilePath | CiteprocFilter -- built-in citeproc - deriving (Show, Generic) + deriving (Show, Generic, Eq) instance FromJSON Filter where parseJSON node = diff --git a/test/command/7329.md b/test/command/7329.md index b5f590d7b..623ee8126 100644 --- a/test/command/7329.md +++ b/test/command/7329.md @@ -27,7 +27,12 @@ % pandoc -f markdown -t org -C --bibliography command/biblio.bib - [@item1] ^D -- [cite:@item1] +- (Doe 2005) + +<<refs>> + +<<ref-item1>> +Doe, John. 2005. /First Book/. Cambridge: Cambridge University Press. ``` |
