Open tomduck opened 5 years ago
Thanks for the attention you're giving to this @tomduck
Just so you do not duplicate some analysis work I've done, here's my take on what needs to be patched in pandoc for this to become possible: https://github.com/jgm/pandoc/issues/5619
Thanks, @ociule. Note that the markdown cross-referencing spec was designed by @scaramouche1 in this post. Something similar would be needed for rst.
I don't expect to get to this soon, but want to keep tabs on the idea for future reference. There is a new 2.0.0 branch I am finalizing at the moment.
I'm very happy to report that rst support already works in pandoc-tablenos.
One just has to use the same trick md tables use, adding an id like `{#tbl:a} to the table caption.
Here's a working example rst example:
.. table:: Demonstration of a simple table. {#tbl:a}
:widths: auto
===== =====
A not A
===== =====
False True
True False
===== =====
As reported in https://github.com/jgm/pandoc/issues/5619 this is transformed in the following native code:
[Table [Str "Table:",Space,Str "Demonstration",Space,Str "of",Space,Str "a",Space,Str "simple",Space,Str "table.",Space,Str "{#tbl:a}"] [AlignDefault,AlignDefault] [0.0,0.0]
[[Plain [Str "A"]]
,[Plain [Str "not",Space,Str "A"]]]
[[[Plain [Str "False"]]
,[Plain [Str "True"]]]
,[[Plain [Str "True"]]
,[Plain [Str "False"]]]]]
Even if the {#tbl:a}
bit was never parsed by pandoc, it is parsed by pandoc-tablenos (possibly py pandocfilters) so this works out of the box. I think documenting this would be valuable.
Edit: this works for numbering the tables, not for referencing them. Can't find a way to get a Citation element out of pandoc with rst input.
That is good to hear. Maybe it won't be a difficult as I first thought.
The same trick does not work in fignos. The rst fragment:
.. figure:: img1.jpg
:name: The number one. {#fig:1}
:width: 1in
The number one. {#fig:1}
The name option is ignored by pandoc.Readers.RST anyway.
I am very interested in what pandoc-fignos does, but work with RST. It would be great if fignos handled rst input as well.
Originally posted by @ociule in https://github.com/tomduck/pandoc-fignos/issues/34#issuecomment-502037940