Skip to content

Commit 10f75f5

Browse files
committed
Merge branch 'albert-github-feature/issue_12113'
2 parents a367f2b + 11f38eb commit 10f75f5

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/docparser.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ Token DocParser::handleStyleArgument(DocNodeVariant *parent,DocNodeList &childre
627627
AUTO_TRACE("cmdName={}",cmdName);
628628
QCString saveCmdName = cmdName;
629629
Token tok=tokenizer.lex();
630+
size_t styleStackSizeAtStart = context.styleStack.size();
630631
if (!tok.is(TokenRetval::TK_WHITESPACE))
631632
{
632633
warn_doc_error(context.fileName,tokenizer.getLineNr(),"expected whitespace after \\{} command",
@@ -643,7 +644,11 @@ Token DocParser::handleStyleArgument(DocNodeVariant *parent,DocNodeList &childre
643644
reg::match(context.token->name.str(),specialChar))
644645
{
645646
// special character that ends the markup command
646-
AUTO_TRACE_ADD("special character ending style argument: '{}'",context.token->name);
647+
AUTO_TRACE_ADD("special character ending style argument: '{}' styleStackSize {}->{}",context.token->name,styleStackSizeAtStart,context.styleStack.size());
648+
if (context.styleStack.size() > styleStackSizeAtStart) // new styles opened inside command, but not closed
649+
{
650+
handlePendingStyleCommands(parent,children,context.styleStack.size()-styleStackSizeAtStart);
651+
}
647652
return tok;
648653
}
649654
if (!defaultHandleToken(parent,tok,children))
@@ -739,9 +744,9 @@ void DocParser::handleStyleLeave(DocNodeVariant *parent,DocNodeList &children,
739744
* (e.g. a <b> without a </b>). The closed styles are pushed onto a stack
740745
* and entered again at the start of a new paragraph.
741746
*/
742-
void DocParser::handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children)
747+
void DocParser::handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children, size_t numberOfElementsNotToRestore)
743748
{
744-
AUTO_TRACE("context.styleStack.size()={}",context.styleStack.size());
749+
AUTO_TRACE("context.styleStack.size()={} numberOfElementsNotToRestore={}",context.styleStack.size(),numberOfElementsNotToRestore);
745750
if (!context.styleStack.empty())
746751
{
747752
const DocStyleChange *sc = &std::get<DocStyleChange>(*context.styleStack.top());
@@ -750,7 +755,14 @@ void DocParser::handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &c
750755
AUTO_TRACE_ADD("unclosed style at position {}",sc->position());
751756
children.append<DocStyleChange>(this,parent,context.nodeStack.size(),
752757
sc->style(),sc->tagName(),FALSE);
753-
context.initialStyleStack.push(context.styleStack.top());
758+
if (numberOfElementsNotToRestore>0)
759+
{
760+
numberOfElementsNotToRestore--;
761+
}
762+
else // style needs to be restored
763+
{
764+
context.initialStyleStack.push(context.styleStack.top());
765+
}
754766
context.styleStack.pop();
755767
sc = !context.styleStack.empty() ? &std::get<DocStyleChange>(*context.styleStack.top()) : nullptr;
756768
}

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);
137+
void handlePendingStyleCommands(DocNodeVariant *parent,DocNodeList &children, size_t numberOfElementsNotToRestore = 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)