pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

DocBook writer: output identifiers of figure blocks

Open Flupp opened this issue 2 years ago • 5 comments

@reviewer: I am not sure if the id needs to be prefixed with writerIdentifierPrefix opts as done in line 190 (this is the only place where the prefix is added AFAICT).

Flupp avatar Feb 09 '23 10:02 Flupp

Note: In contrast to the DocBook writer, the DocBook reader already supports the identifier.

Behavior before the change:

$ pandoc -f Markdown -t docbook <<<'![caption text](file.svg){#testid}' | pandoc -f docbook -t markdown 
![caption text](file.svg "fig:")

Behavior after the change:

$ pandoc -f Markdown -t docbook <<<'![caption text](file.svg){#testid}' | pandoc -f docbook -t markdown
![caption text](file.svg "fig:"){#testid}

Flupp avatar Feb 09 '23 10:02 Flupp

Docs for --id-prefix say "Specify a prefix to be added to all identifiers and internal links in HTML and DocBook output," so yes, I'd say it should be added in this case too.

jgm avatar Feb 09 '23 16:02 jgm

I’ve added the prefix. However, now I seriously wonder if the prefix is maybe also missing at other places in the DocBook writer. The following

:::{#bar}
bar div
:::

:::{#sec .section}
sec div
:::

[foo link](#foo)

[span]{#spanid}

![caption text](file.svg){#testid}

translates via pandoc --id-prefix=prefix- -f Markdown -t docbook (including this change) to

<para xml:id="bar">
  bar div
</para>
<para xml:id="sec">
  sec div
</para>
<para>
  <link linkend="prefix-foo">foo link</link>
</para>
<para>
  <anchor xml:id="spanid" />span
</para>
<figure xml:id="prefix-testid">
  <title>caption text</title>
  <mediaobject>
    <imageobject>
      <imagedata fileref="file.svg" />
    </imageobject>
    <textobject><phrase>caption text</phrase></textobject>
  </mediaobject>
</figure>

Note that prefix- is not added to every id.

Flupp avatar Feb 09 '23 18:02 Flupp

Hi, I'm sorry I let this languish so long.

You're right that the prefix isn't added everywhere it should be. Perhaps that could be addressed in a separate PR. Or, feel free to address it here.

I'll add one substantive comment to your code above.

jgm avatar Dec 06 '23 16:12 jgm

It would also be great to have a test. Simplest way is a "command test" called test/command/8608.md. See the other files in that directory for examples.

jgm avatar Dec 06 '23 16:12 jgm