tomtom-international / asciidoxy

AsciiDoxy generates API documentation from Doxygen XML output to AsciiDoc.
Apache License 2.0
31 stars 10 forks source link

Reference IDs with double underscores in descriptions yield invalid links #69

Closed Sycophantic-Witty closed 2 years ago

Sycophantic-Witty commented 2 years ago

Language traits unique_id() already includes a workaround for '__' pairs in IDs misinterpreted as AsciiDoc "unconstrained quotes". The same issue makes references in description text generate invalid hyperlinks.

The hack below "solves" the issue for me. A better fix would probably factor out sanitation of any ID text though.

diff --git a/asciidoxy/parser/doxygen/description_parser.py b/asciidoxy/parser/doxygen/description_parser.py
index ee13e5f..671f492 100644
--- a/asciidoxy/parser/doxygen/description_parser.py
+++ b/asciidoxy/parser/doxygen/description_parser.py
@@ -925,7 +925,9 @@ class Ref(NestedDescriptionElement):

     def __init__(self, language_tag: str, refid: str, kindref: str, *contents: DescriptionElement):
         super().__init__(language_tag, *contents)
-        self.refid = refid
+        # Workaround a bug in asciidoctor: if there is an occurrence of __ the ref is not parsed
+        # correctly: #2746
+        self.refid = refid.replace("__", "-")
         self.kindref = kindref

     def to_asciidoc(self, context: AsciiDocContext = None) -> str:
silvester747 commented 2 years ago

Thank you for your report. It makes sense to factor out the sanitation. I will make a 0.8.x bug fix release for this.