jgm/pandoc

Section Cross Reference ID is removed when converting from Quarto markdown to markdown_strict

Watterry opened this issue · 1 comments

Explain the problem.

I am using Pandoc to convert Quarto markdown to Hugo markdown which we also can call as markdown_strict. The section is writing like this:

### using for anchor test {#sec-using-for-anchor-test}

Just for test

Try to cross reference the section here:
[@sec-using-for-anchor-test]

Then I use the following command to do the conversion:

pandoc --citeproc --bibliography reference.bib --csl ieee.csl -f markdown -t markdown_strict -o result.md index.qmd

In the output file result.md, the section cross reference is missing. The converted content is shown below:

### using for anchor test

Just for test

Try to cross reference the section here: \[@sec-using-for-anchor-test\]

And Pandoc provides a warning:

[WARNING] Citeproc: citation sec-using-for-anchor-test not found

I think this is a bug: maybe the cross reference ID is dropped by Pandoc.

Pandoc version?

The Pandoc version is:

pandoc 3.1.11
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: C:\Users\Administrator\AppData\Roaming\pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

The [@sec-...] syntax for cross-references is Quarto-specific. Furthermore, markdown_strict does not support heading attributes.

I'd recommend to use Quarto and to target the hugo-md format. The closest pandoc formats are gfm or commonmark_x Markdown, but you might have to tweak format extensions.