summaryrefslogtreecommitdiffstats
path: root/src/docbookvisitor.cpp
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2019-08-12 16:51:01 (GMT)
committeralbert-github <albert.tests@gmail.com>2019-08-12 16:51:01 (GMT)
commita390d6a9ad62019c7ca3d3689184fd3ce6afd57c (patch)
tree39eff42bc750d1cdd7ba4347fb7fadb1a6da330c /src/docbookvisitor.cpp
parent3e8fe63473b047bf3d48c734750334244e9981a8 (diff)
downloadDoxygen-a390d6a9ad62019c7ca3d3689184fd3ce6afd57c.zip
Doxygen-a390d6a9ad62019c7ca3d3689184fd3ce6afd57c.tar.gz
Doxygen-a390d6a9ad62019c7ca3d3689184fd3ce6afd57c.tar.bz2
Incorrect NCName in docbook citations
In a bibtex reference it is possible to have a colon as the id, but in docbook this will result in: ``` docbook/citelist.xml:5: validity error : xml:id : attribute value _citelist_1CITEREF_pre:post is not an NCName <varlistentry><term><anchor xml:id="_citelist_1CITEREF_pre:post"/>[1]</term> ``` So the id has to be translated. A colon in an id can only happen in case the names is provided from the outside.
Diffstat (limited to 'src/docbookvisitor.cpp')
-rw-r--r--src/docbookvisitor.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp
index ce3a845..83c34e7 100644
--- a/src/docbookvisitor.cpp
+++ b/src/docbookvisitor.cpp
@@ -36,6 +36,7 @@
#include "htmlentity.h"
#include "emoji.h"
#include "plantuml.h"
+#include "growbuf.h"
#if 0
#define DB_VIS_C DB_VIS_C1(m_t)
@@ -49,6 +50,25 @@
#define DB_VIS_C2a(x,y)
#endif
+static QCString filterId(const char *s)
+{
+ static GrowBuf growBuf;
+ growBuf.clear();
+ if (s==0) return "";
+ const unsigned char *p=(const unsigned char *)s;
+ char c;
+ while ((c=*p++))
+ {
+ switch (c)
+ {
+ case ':': growBuf.addStr("_1"); break;
+ default: growBuf.addChar(c); break;
+ }
+ }
+ growBuf.addChar(0);
+ return growBuf.get();
+}
+
void DocbookDocVisitor::visitCaption(const QList<DocNode> &children)
{
QListIterator<DocNode> cli(children);
@@ -374,7 +394,7 @@ void DocbookDocVisitor::visit(DocAnchor *anc)
{
DB_VIS_C
if (m_hide) return;
- m_t << "<anchor xml:id=\"_" << stripPath(anc->file()) << "_1" << anc->anchor() << "\"/>";
+ m_t << "<anchor xml:id=\"_" << stripPath(anc->file()) << "_1" << filterId(anc->anchor()) << "\"/>";
}
void DocbookDocVisitor::visit(DocInclude *inc)
@@ -550,7 +570,7 @@ void DocbookDocVisitor::visit(DocCite *cite)
{
DB_VIS_C
if (m_hide) return;
- if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor());
+ if (!cite->file().isEmpty()) startLink(cite->file(),filterId(cite->anchor()));
filter(cite->text());
if (!cite->file().isEmpty()) endLink();
}