Skip to content

Commit 081bfa3

Browse files
committed
issue doxygen#12113 Doxygen generates ill-formed XML when \p is at the end of a line
Also fixes invalid XML for this case. ```C++ /** @file */ /** * <b> * Evaluates @p * *result,* * * @p binary_op * </b> */ int x; ```
1 parent 10f75f5 commit 081bfa3

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

src/docparser.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -744,27 +744,22 @@ void DocParser::handleStyleLeave(DocNodeVariant *parent,DocNodeList &children,
744744
* (e.g. a <b> without a </b>). The closed styles are pushed onto a stack
745745
* and entered again at the start of a new paragraph.
746746
*/
747-
void DocParser::handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children, size_t numberOfElementsNotToRestore)
747+
void DocParser::handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children, size_t numberOfElementsToClose)
748748
{
749-
AUTO_TRACE("context.styleStack.size()={} numberOfElementsNotToRestore={}",context.styleStack.size(),numberOfElementsNotToRestore);
749+
AUTO_TRACE("context.styleStack.size()={} numberOfElementsToClose={}",context.styleStack.size(),numberOfElementsToClose);
750750
if (!context.styleStack.empty())
751751
{
752+
if (numberOfElementsToClose==0) numberOfElementsToClose = context.styleStack.size(); // 0 is special value for "close all"
752753
const DocStyleChange *sc = &std::get<DocStyleChange>(*context.styleStack.top());
753-
while (sc && sc->position()>=context.nodeStack.size())
754+
while (sc && sc->position()>=context.nodeStack.size() && numberOfElementsToClose>0)
754755
{ // there are unclosed style modifiers in the paragraph
755-
AUTO_TRACE_ADD("unclosed style at position {}",sc->position());
756+
AUTO_TRACE_ADD("unclosed style {} at position {}",sc->styleString(),sc->position());
756757
children.append<DocStyleChange>(this,parent,context.nodeStack.size(),
757758
sc->style(),sc->tagName(),FALSE);
758-
if (numberOfElementsNotToRestore>0)
759-
{
760-
numberOfElementsNotToRestore--;
761-
}
762-
else // style needs to be restored
763-
{
764-
context.initialStyleStack.push(context.styleStack.top());
765-
}
759+
context.initialStyleStack.push(context.styleStack.top());
766760
context.styleStack.pop();
767761
sc = !context.styleStack.empty() ? &std::get<DocStyleChange>(*context.styleStack.top()) : nullptr;
762+
numberOfElementsToClose--;
768763
}
769764
}
770765
}

src/docparser_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class DocParser : public IDocParser
134134
const QCString &tagName,const HtmlAttribList *attribs);
135135
void handleStyleLeave(DocNodeVariant *parent,DocNodeList &children, DocStyleChange::Style s,
136136
const QCString &tagName);
137-
void handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children, size_t numberOfElementsNotToRestore = 0);
137+
void handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children, size_t numberOfElementsToClose = 0);
138138
void handleInitialStyleCommands(DocNodeVariant *parent,DocNodeList &children);
139139
Token handleAHref(DocNodeVariant *parent,DocNodeList &children,const HtmlAttribList &tagHtmlAttribs);
140140
void handleUnclosedStyleCommands();

0 commit comments

Comments
 (0)