jelovirt / org.lwdita

LwDITA parser for DITA-OT
http://lwdita.org/
Apache License 2.0
25 stars 19 forks source link

Anchored links to titles in PDF don't work when `{.section}` is defined #220

Closed amyhiggins closed 5 months ago

amyhiggins commented 5 months ago

If I create an anchor link to a header, it works fine until I add the {.section} class header.

I build using WebHelp and PDF. In WebHelp, I can see the anchor link in the URL, so for file.md:

# Title1 {#id1 .concept}

## Title2 {#id2 .section}

Without {.section}, the anchor link is [link to Title2](file.md#id2) and works with both build formats. With {.section}, I have to change the link to [link to Title2](file.md#id1__id2), but the link doesn't work in PDF.

jelovirt commented 5 months ago

While file.md is a Markdown file and Markdown uses the same link conventions as HTML, this is not the case with LwDITA parser. The LwDITA parser processes Markdown in the DITA realm and the links are processed as DITA links.

This means the correct link to #id2 is [link to Title2](file.md#id1/id2). This is equivalent to XML DITA link <xref href="file.md#id1/id2">link to Title2</>.

jelovirt commented 5 months ago

This was missing from the wiki docs. Added an example to end of https://github.com/jelovirt/org.lwdita/wiki/Common-syntax#links

jelovirt commented 5 months ago

It is possible to add a DITA-OT feature that attemps to recover from linking to file.md#id2 and rewrite the link to file.md#id1/id2, but it's out of scope for the LwDITA parser.

amyhiggins commented 5 months ago

Oh how did I not think of that... thanks!