Skip to content

Commit

Permalink
a named anchor does not need custom attributes and minor other correc…
Browse files Browse the repository at this point in the history
…tions.
  • Loading branch information
doxygen committed Feb 17, 2019
1 parent bf0e769 commit b4bf112
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/docparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ static int handleAHref(DocNode *parent,QList<DocNode> &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
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -6866,9 +6866,10 @@ int DocPara::parse()
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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/docparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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 */
Expand Down Expand Up @@ -1215,6 +1212,7 @@ class DocPara : public CompAccept<DocPara>

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;
Expand Down
2 changes: 2 additions & 0 deletions src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,9 @@ void HtmlDocVisitor::visitPre(DocHtmlTable *t)
{
QCString anc = t->caption()->anchor();
if (!anc.isEmpty())
{
m_t << "<a class=\"anchor\" id=\"" << anc << "\"></a>\n";
}
}

QString attrs = htmlAttribsToString(t->attribs());
Expand Down

0 comments on commit b4bf112

Please sign in to comment.