Skip to content

Commit

Permalink
Disable citations extension in writers if --citeproc is used.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jgm committed Mar 5, 2025
1 parent b58381a commit e73b9ee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
9 changes: 4 additions & 5 deletions MANUAL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
7 changes: 6 additions & 1 deletion src/Text/Pandoc/App/OutputSettings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Filter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
7 changes: 6 additions & 1 deletion test/command/7329.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```


Expand Down

0 comments on commit e73b9ee

Please sign in to comment.