From b4bf112632354be795da81a9c0660eebf2ec81e5 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 17 Feb 2019 21:09:36 +0100 Subject: a named anchor does not need custom attributes and minor other corrections. --- src/docparser.cpp | 11 ++++++----- src/docparser.h | 6 ++---- src/htmldocvisitor.cpp | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/docparser.cpp b/src/docparser.cpp index 47c0c8c..aff7411 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -1042,7 +1042,7 @@ static int handleAHref(DocNode *parent,QList &children,const HtmlAttrib // and remove the href attribute bool result = attrList.remove(index); ASSERT(result); - DocAnchor *anc = new DocAnchor(parent,opt->value,TRUE,attrList); + DocAnchor *anc = new DocAnchor(parent,opt->value,TRUE); children.append(anc); break; // stop looking for other tag attribs } @@ -1934,7 +1934,7 @@ DocLinkedWord::DocLinkedWord(DocNode *parent,const QCString &word, //--------------------------------------------------------------------------- -void DocAnchor::docAnchorInit(DocNode *parent,const QCString &id,bool newAnchor) +DocAnchor::DocAnchor(DocNode *parent,const QCString &id,bool newAnchor) { m_parent = parent; if (id.isEmpty()) @@ -6866,9 +6866,10 @@ endparagraph: DocNode *n = g_nodeStack.pop(); ASSERT(n==this); DBG(("DocPara::parse() end retval=%x\n",retval)); - if (!g_token->endTag && retval == TK_NEWPARA && g_token->name.lower() == "p") + if (!g_token->endTag && n->kind()==DocNode::Kind_Para && + retval==TK_NEWPARA && g_token->name.lower() == "p") { - ((DocPara *)n) -> m_attribs = g_token->attribs; + ((DocPara *)n)->setAttribs(g_token->attribs); } INTERNAL_ASSERT(retval==0 || retval==TK_NEWPARA || retval==TK_LISTITEM || retval==TK_ENDLIST || retval>RetVal_OK @@ -7137,7 +7138,7 @@ void DocRoot::parse() DocPara *par = new DocPara(this); if (isFirst) { par->markFirst(); isFirst=FALSE; } retval=par->parse(); - if (!par->isEmpty() || par->attribs().count()) + if (!par->isEmpty() || par->attribs().count()>0) { m_children.append(par); lastPar=par; diff --git a/src/docparser.h b/src/docparser.h index 7363232..d36ed6c 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -331,9 +331,7 @@ class DocHorRuler : public DocNode class DocAnchor : public DocNode { public: - DocAnchor(DocNode *parent,const QCString &id,bool newAnchor){docAnchorInit(parent,id,newAnchor);} - DocAnchor(DocNode *parent,const QCString &id,bool newAnchor,const HtmlAttribList &attribs) : m_attribs(attribs) - {docAnchorInit(parent,id,newAnchor);} + DocAnchor(DocNode *parent,const QCString &id,bool newAnchor); Kind kind() const { return Kind_Anchor; } QCString anchor() const { return m_anchor; } QCString file() const { return m_file; } @@ -345,7 +343,6 @@ class DocAnchor : public DocNode QCString m_anchor; QCString m_file; HtmlAttribList m_attribs; - void docAnchorInit(DocNode *parent,const QCString &id,bool newAnchor); }; /** Node representing a citation of some bibliographic reference */ @@ -1215,6 +1212,7 @@ class DocPara : public CompAccept bool injectToken(int tok,const QCString &tokText); const HtmlAttribList &attribs() const { return m_attribs; } + void setAttribs(const HtmlAttribList &attribs) { m_attribs = attribs; } private: QCString m_sectionId; diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 67fc98d..2b6b359 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -1494,7 +1494,9 @@ void HtmlDocVisitor::visitPre(DocHtmlTable *t) { QCString anc = t->caption()->anchor(); if (!anc.isEmpty()) + { m_t << "\n"; + } } QString attrs = htmlAttribsToString(t->attribs()); -- cgit v0.12