From 0ee3c373963c91bc5cbaf220764483a6f05d977e Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 7 Jun 2021 15:04:25 +0200 Subject: Problem with cite command (tests 12) When running a link checker over the (x)html results of the doxygen tests 12 and subdirs enabled we get the error: ``` Processing file:///.../testing/test_output_012/html/d0/de3/citelist.xhtml List of broken links and other issues: file:///..../testing/test_output_012/html/ Lines: 70, 74 Code: 200 (no message) To do: Some of the links to this resource point to broken URI fragments (such as index.html#fragment). The following fragments need to be fixed: CITEREF_LeLe12 Lines: 70, 74 ``` Also looking at the results of rtf and docbook output we see incorrect links. With the rtf links there is a subsequent problem of not returning the right "label" (see util.h). --- src/docbookvisitor.cpp | 9 ++++++++- src/docparser.cpp | 4 +++- src/docparser.h | 6 ++++-- src/rtfdocvisitor.cpp | 7 +++---- src/util.cpp | 6 ++++++ 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 0bc2042..65081ef 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -1190,7 +1190,14 @@ void DocbookDocVisitor::visitPre(DocHRef *href) { DB_VIS_C if (m_hide) return; - m_t << "url()) << "\">"; + if (href->url().at(0) != '#') + { + m_t << "url()) << "\">"; + } + else + { + startLink(href->file(),filterId(href->url().mid(1))); + } } void DocbookDocVisitor::visitPost(DocHRef *) diff --git a/src/docparser.cpp b/src/docparser.cpp index 4e316a8..fa468c0 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -1016,7 +1016,9 @@ static int handleAHref(DocNode *parent,DocNodeList &children,const HtmlAttribLis HtmlAttribList attrList = tagHtmlAttribs; // and remove the href attribute attrList.erase(attrList.begin()+index); - DocHRef *href = new DocHRef(parent,attrList,opt.value,g_relPath); + QCString relPath; + if (opt.value.at(0) != '#') relPath = g_relPath; + DocHRef *href = new DocHRef(parent,attrList,opt.value,relPath,convertNameToFile(g_fileName,FALSE,TRUE)); children.push_back(std::unique_ptr(href)); g_insideHtmlLink=TRUE; retval = href->parse(); diff --git a/src/docparser.h b/src/docparser.h index f256c56..e76dc16 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -915,10 +915,11 @@ class DocHRef : public CompAccept { public: DocHRef(DocNode *parent,const HtmlAttribList &attribs,const QCString &url, - const QCString &relPath) : - m_attribs(attribs), m_url(url), m_relPath(relPath) { m_parent = parent; } + const QCString &relPath, const QCString &file) : + m_attribs(attribs), m_url(url), m_relPath(relPath), m_file(file) { m_parent = parent; } int parse(); QCString url() const { return m_url; } + QCString file() const { return m_file; } QCString relPath() const { return m_relPath; } Kind kind() const override { return Kind_HRef; } const HtmlAttribList &attribs() const { return m_attribs; } @@ -926,6 +927,7 @@ class DocHRef : public CompAccept private: HtmlAttribList m_attribs; QCString m_url; + QCString m_file; QCString m_relPath; }; diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index b1df440..025cc90 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -1135,12 +1135,11 @@ void RTFDocVisitor::visitPre(DocHRef *href) DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHRef)}\n"); if (Config_getBool(RTF_HYPERLINKS)) { - if (href->url().startsWith("#CITEREF")) + if (href->url().startsWith("#")) { - // when starting with #CITEREF it is a doxygen generated "url"a - // so a local link + // when starting with # so a local link QCString cite; - cite = "citelist_" + href->url().right(href->url().length()-1); + cite = href->file() + "_" + href->url().right(href->url().length()-1); m_t << "{\\field " "{\\*\\fldinst " "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" " diff --git a/src/util.cpp b/src/util.cpp index 37c5e62..b51fe44 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -5179,6 +5179,12 @@ QCString rtfFormatBmkStr(const QCString &name) // substitute a short arbitrary string for the name // supplied, and keep track of the correspondence // between names and strings. + auto it = g_tagMap.find(name.str()); + if (it!=g_tagMap.end()) // already known + { + return QCString(it->second); + } + QCString tag = g_nextTag; auto result = g_tagMap.insert( std::make_pair(name.str(), g_nextTag.str()) ); -- cgit v0.12