jgm / pandoc

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

Suggested ODT table improvement #2529

Open ghost opened 9 years ago

ghost commented 9 years ago

I think for someone who can read the haskell this should be pretty easy to change. It goes hand in hand with #2401 but doesn't involve frames, making it simpler overall.

Currently a table caption always output below the table in ODT, regardless of position in markdown, and is output with no label/number using:

<text:p text:style-name="TableCaption">The Caption</text:p>

I suggest this replacement, to be inserted before or after the table according to the position in the markdown:

<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable0" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">1</text:sequence>: The Caption</text:p>

This would mean subsequent edits using libreoffice would update the numbering automatically, and makes a list of tables possible.

The text:ref-name attribute might not be necessary, as libreoffice seems to put it back in on next save, but as being as the writer needs to count tables anyway I see no reason not to add it.

jgm commented 9 years ago

The writer only sees the Pandoc AST, not the original Markdown source, and so doesn't have access to information about whether the caption was placed before or after the table. So the proposed fix isn't possible (without revision to the structure of the Pandoc AST).

ghost commented 9 years ago

Ok. I didn't realise that the writer had no knowledge of where the caption was in relation to the table. In that case, I stand by my suggested change to the xml inserted, and suggest something like what was done for docx in #1794 to deal with the position of the caption,