Skip to content

Commit e73b9ee

Browse files
committedMar 5, 2025·
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.
1 parent b58381a commit e73b9ee

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed
 

‎MANUAL.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -1505,11 +1505,10 @@ header when requesting a document from a URL:
15051505
order they appear on the command line. For more
15061506
information, see the section on [Citations].
15071507

1508-
Note: if your target format is `markdown`, `org`, or `typst`,
1509-
you will need to disable the `citations` extension (e.g., `-t
1510-
markdown-citations`) to see the rendered citations and
1511-
bibliography. Otherwise the format's own citation syntax will
1512-
be used.
1508+
Note: if this option is specified, the `citations` extension
1509+
will be disabled automatically in the writer, to ensure that
1510+
the citeproc-generated citations will be rendered instead of
1511+
the format's own citation syntax.
15131512

15141513
`--bibliography=`*FILE*
15151514

‎src/Text/Pandoc/App/OutputSettings.hs

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import System.FilePath
3838
import System.IO (stdout)
3939
import Text.Pandoc.Chunks (PathTemplate(..))
4040
import Text.Pandoc
41+
import Text.Pandoc.Filter (Filter(CiteprocFilter))
4142
import Text.Pandoc.App.Opt (Opt (..))
4243
import Text.Pandoc.App.CommandLineOptions (engines)
4344
import Text.Pandoc.Format (FlavoredFormat (..), applyExtensionsDiff,
@@ -121,7 +122,7 @@ optToOutputSettings scriptingEngine opts = do
121122
then getAndCompile (tp <.> T.unpack format)
122123
else throwError e)
123124

124-
(writer, writerExts, mtemplate) <-
125+
(writer, writerExts', mtemplate) <-
125126
if "lua" `T.isSuffixOf` format
126127
then do
127128
let path = T.unpack format
@@ -150,6 +151,10 @@ optToOutputSettings scriptingEngine opts = do
150151
tmpl <- processCustomTemplate (compileDefaultTemplate format)
151152
return (w, wexts, tmpl)
152153

154+
-- see #10662:
155+
let writerExts = if CiteprocFilter `elem` optFilters opts
156+
then disableExtension Ext_citations writerExts'
157+
else writerExts'
153158

154159
let addSyntaxMap existingmap f = do
155160
res <- liftIO (parseSyntaxDefinition f)

‎src/Text/Pandoc/Filter.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import Control.Monad (foldM, when)
4141
data Filter = LuaFilter FilePath
4242
| JSONFilter FilePath
4343
| CiteprocFilter -- built-in citeproc
44-
deriving (Show, Generic)
44+
deriving (Show, Generic, Eq)
4545

4646
instance FromJSON Filter where
4747
parseJSON node =

‎test/command/7329.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
% pandoc -f markdown -t org -C --bibliography command/biblio.bib
2828
- [@item1]
2929
^D
30-
- [cite:@item1]
30+
- (Doe 2005)
31+
32+
<<refs>>
33+
34+
<<ref-item1>>
35+
Doe, John. 2005. /First Book/. Cambridge: Cambridge University Press.
3136
```
3237

3338

0 commit comments

Comments
 (0)
Please sign in to comment.