tomduck / pandoc-fignos

A pandoc filter for numbering figures and figure references.
GNU General Public License v3.0
331 stars 25 forks source link

"Bad reference" - syntax doesn't work on recent pandoc releases #107

Open dmitryperets opened 9 months ago

dmitryperets commented 9 months ago

Using pandoc 3.1 (after successfully applying the regex fix from #105). While other filters from the pandoc-xnos family started working, pandoc-fignos is still broken.

Here is a simple example:

Keys    Values
-----   -------
Key1    Value1
Key2    Value2

Table: Silly Table {#tbl:silly}

![Figure](images/test.png){#fig:strange}

This table is +@tbl:silly.

This figure is +@fig:strange.

You can see here one table (using pandoc-tablenos) and one figure (using pandoc-fignos). Both worked fine with pandoc 2.x. But now only the table numbering works, not the figure numbering:

% pandoc test.md --filter pandoc-xnos -o test.html

pandoc-fignos: Bad reference: @fig:strange.

Output:

<div id="tbl:silly" class="tablenos">
<table id="tbl:silly">
<caption><span>Table 1:</span> Silly Table </caption>
<thead>
<tr class="header">
<th style="text-align: left;">Keys</th>
<th style="text-align: left;">Values</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Key1</td>
<td style="text-align: left;">Value1</td>
</tr>
<tr class="even">
<td style="text-align: left;">Key2</td>
<td style="text-align: left;">Value2</td>
</tr>
</tbody>
</table>
</div>
<figure id="fig:strange">
<img src="images/test.png" title="fig:" alt="Figure" />
<figcaption aria-hidden="true">Figure</figcaption>
</figure>
<p>This table is table <a href="#tbl:silly">1</a>.</p>
<p>This figure is fig. ??.</p>
dmitryperets commented 9 months ago

Looking deeper, looks like Pandoc 3.x has introduced some significant changes to the AST, specifically adding a new object type "Figure": https://github.com/jgm/pandoc/issues/3177, https://github.com/jgm/pandoc/issues/7184

So no wonder that pandoc-fignos doesn't handle it correctly. The only question is who can update it now =)