jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.78k stars 3.39k forks source link

DOI Rendered as Hyperlink in Bibliography Despite CSL Customization #10393

Closed TomBener closed 2 days ago

TomBener commented 3 days ago

Description

When using Pandoc with a custom CSL file to generate bibliographies, the DOI is rendered as a hyperlink for the title of an entry, even if the CSL file does not include a macro or instructions to do so. This behavior is inconsistent with tools like the Zotero Word plugin, which correctly follows the CSL specification.

Steps to Reproduce

  1. Use the following Markdown file as input:

    ---
    title: Test CSL without DOI
    csl: chicago-author-date-without-doi.csl
    reference-section-title: References
    references:
    - author:
    - family: Acemoglu
     given: Daron
    - family: De Feo
     given: Giuseppe
    - family: De Luca
     given: Giacomo
    - family: Russo
     given: Gianluca
    container-title: The Quarterly Journal of Economics
    doi: 10.1093/qje/qjac001
    id: acemoglu2022
    issue: 2
    issued: 2022-05-01
    page: 1233-1296
    title: "War, socialism, and the rise of fascism: An empirical exploration"
    title-short: War, socialism, and the rise of fascism
    type: article-journal
    volume: 137
    ---
    
    # Test Citation
    
    @acemoglu2022
  2. Use this CSL file, which omits any DOI macro.

  3. Run the following Pandoc command:

pandoc test.md -t html -C
  1. Inspect the output.

Expected Behavior

The bibliography should render without the title being hyperlinked to the DOI unless explicitly specified in the CSL file.

Actual Behavior

The title in the bibliography is hyperlinked to the DOI, despite the CSL file having no such macro or instructions:

<h1 id="test-citation">Test citation</h1>
<p><span class="citation" data-cites="acemoglu2022">Acemoglu et al.
(2022)</span></p>
<h1 id="test-citation-1">Test citation</h1>
<p><span class="citation" data-cites="acemoglu2022">Acemoglu et al.
(2022)</span></p>
<h1 class="unnumbered" id="bibliography">References</h1>
<div id="refs" class="references csl-bib-body hanging-indent"
data-entry-spacing="0" role="list">
<div id="ref-acemoglu2022" class="csl-entry" role="listitem">
Acemoglu, Daron, Giuseppe De Feo, Giacomo De Luca, and Gianluca Russo.
2022. <span>“<a href="https://doi.org/10.1093/qje/qjac001">War,
Socialism, and the Rise of Fascism: An Empirical
Exploration</a>.”</span> <em>The Quarterly Journal of Economics</em> 137
(2): 1233–96.
</div>
</div>

Notes

This behavior is not observed in the Zotero Word plugin when using the same CSL file. It seems Pandoc may be applying default handling for DOIs that overrides or bypasses the CSL configuration. The Pandoc version is 3.5.

jgm commented 3 days ago

I believe we are following the spec here: https://docs.citationstyles.org/en/stable/specification.html#appendix-vi-links

There is no specific configuration in CSL for hyperlinks, as far as I know.

TomBener commented 2 days ago

I believe we are following the spec here: https://docs.citationstyles.org/en/stable/specification.html#appendix-vi-links

There is no specific configuration in CSL for hyperlinks, as far as I know.

Thanks. I understand it, but is there any method to disable the hyperlinks of DOI as some journal styles don’t need it.

jgm commented 2 days ago

You could use a Lua filter (put it after --citeproc on the command line so that it operates after citeproc). The filter would look inside the refs Div and delinkify any links there. See the docs for Lua filters.