lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
948 stars 76 forks source link

code listings without ids ignored by crossref #247

Open bjhijmans opened 4 years ago

bjhijmans commented 4 years ago

test2.txt has two code blocks, one with an id and one without. After running pandoc test2.txt --filter=/opt/pandoc-crossref -t html the results are as follows:

<pre data-caption="Caption1"><code>Code</code></pre>
<div id="lst:1" class="listing">
<p>Listing 1: Caption2</p>
<pre><code>Code</code></pre>
</div>

I would expect to see something closer to

<div class="listing">
<p>Listing 1: Caption1</p>
<pre><code>Code</code></pre>
</div>
<div id="lst:1" class="listing">
<p>Listing 2: Caption2</p>
<pre><code>Code</code></pre>
</div>

It doesn't make sense to me that I can't get captions and incremented numbering without providing an id.

lierdakil commented 4 years ago

This is by design. Which is perhaps somewhat unintuitive, but pandoc-crossref tries to be conservative, which means it doesn't touch things it's not sure what to do with.

At the moment, pandoc-crossref can be coerced to make two exceptions: for sections (autoSectionLabels) and equations (autoEqnLabels). I'm going to treat this as a feature request. Can't promise I'll get to it soon though.