summaryrefslogtreecommitdiffstats
path: root/src/htmldocvisitor.cpp
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2018-11-24 17:18:01 (GMT)
committeralbert-github <albert.tests@gmail.com>2018-11-24 17:18:01 (GMT)
commitf923f26d602fd991577b7a6676d129bd1642f453 (patch)
tree6c52d3730be9a1fb53553757e131642e236978fc /src/htmldocvisitor.cpp
parent50879dd77d551cd62c5a6db2f3f322ae69b115b7 (diff)
downloadDoxygen-f923f26d602fd991577b7a6676d129bd1642f453.zip
Doxygen-f923f26d602fd991577b7a6676d129bd1642f453.tar.gz
Doxygen-f923f26d602fd991577b7a6676d129bd1642f453.tar.bz2
Incorrect number of start / end paragraph tags for xhtml with htmlonly
In case of `\htmlonly[block]` the a force closed paragraph is not always force opened again. Problem can be seen with the default doxygen test 20 (`[020_only.dox]: test the \*only and \*endonly commands`).
Diffstat (limited to 'src/htmldocvisitor.cpp')
-rw-r--r--src/htmldocvisitor.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index ba10ca1..e1ac6d6 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -444,9 +444,12 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
forceStartParagraph(s);
break;
case DocVerbatim::HtmlOnly:
- if (s->isBlock()) forceEndParagraph(s);
- m_t << s->text();
- if (s->isBlock()) forceStartParagraph(s);
+ {
+ bool forced = false;
+ if (s->isBlock()) forced = forceEndParagraph(s);
+ m_t << s->text();
+ if (s->isBlock()) forceStartParagraph(s, forced);
+ }
break;
case DocVerbatim::ManOnly:
case DocVerbatim::LatexOnly:
@@ -2277,7 +2280,7 @@ static bool insideStyleChangeThatIsOutsideParagraph(DocPara *para,int nodeIndex)
* have to be outside of the paragraph. This method will forcefully end
* the current paragraph and forceStartParagraph() will restart it.
*/
-void HtmlDocVisitor::forceEndParagraph(DocNode *n)
+bool HtmlDocVisitor::forceEndParagraph(DocNode *n)
{
//printf("forceEndParagraph(%p) %d\n",n,n->kind());
if (n->parent() && n->parent()->kind()==DocNode::Kind_Para)
@@ -2285,7 +2288,7 @@ void HtmlDocVisitor::forceEndParagraph(DocNode *n)
DocPara *para = (DocPara*)n->parent();
int nodeIndex = para->children().findRef(n);
nodeIndex--;
- if (nodeIndex<0) return; // first node
+ if (nodeIndex<0) return false; // first node
while (nodeIndex>=0 &&
para->children().at(nodeIndex)->kind()==DocNode::Kind_WhiteSpace
)
@@ -2296,7 +2299,7 @@ void HtmlDocVisitor::forceEndParagraph(DocNode *n)
{
DocNode *n = para->children().at(nodeIndex);
//printf("n=%p kind=%d outside=%d\n",n,n->kind(),mustBeOutsideParagraph(n));
- if (mustBeOutsideParagraph(n)) return;
+ if (mustBeOutsideParagraph(n)) return false;
}
nodeIndex--;
bool styleOutsideParagraph=insideStyleChangeThatIsOutsideParagraph(para,nodeIndex);
@@ -2304,18 +2307,20 @@ void HtmlDocVisitor::forceEndParagraph(DocNode *n)
bool isLast;
getParagraphContext(para,isFirst,isLast);
//printf("forceEnd first=%d last=%d styleOutsideParagraph=%d\n",isFirst,isLast,styleOutsideParagraph);
- if (isFirst && isLast) return;
- if (styleOutsideParagraph) return;
+ if (isFirst && isLast) return false;
+ if (styleOutsideParagraph) return false;
m_t << "</p>";
+ return true;
}
+ return false;
}
/** Used for items found inside a paragraph, which due to XHTML restrictions
* have to be outside of the paragraph. This method will forcefully start
* the paragraph, that was previously ended by forceEndParagraph().
*/
-void HtmlDocVisitor::forceStartParagraph(DocNode *n)
+void HtmlDocVisitor::forceStartParagraph(DocNode *n, bool forced)
{
//printf("forceStartParagraph(%p) %d\n",n,n->kind());
if (n->parent() && n->parent()->kind()==DocNode::Kind_Para) // if we are inside a paragraph
@@ -2324,9 +2329,9 @@ void HtmlDocVisitor::forceStartParagraph(DocNode *n)
int nodeIndex = para->children().findRef(n);
int numNodes = para->children().count();
bool styleOutsideParagraph=insideStyleChangeThatIsOutsideParagraph(para,nodeIndex);
- if (styleOutsideParagraph) return;
+ if (!forced && styleOutsideParagraph) return;
nodeIndex++;
- if (nodeIndex==numNodes) return; // last node
+ if (!forced && nodeIndex==numNodes) return; // last node
while (nodeIndex<numNodes &&
para->children().at(nodeIndex)->kind()==DocNode::Kind_WhiteSpace
)
@@ -2336,9 +2341,9 @@ void HtmlDocVisitor::forceStartParagraph(DocNode *n)
if (nodeIndex<numNodes)
{
DocNode *n = para->children().at(nodeIndex);
- if (mustBeOutsideParagraph(n)) return;
+ if (!forced && mustBeOutsideParagraph(n)) return;
}
- else
+ else if (!forced)
{
return; // only whitespace at the end!
}
@@ -2348,7 +2353,7 @@ void HtmlDocVisitor::forceStartParagraph(DocNode *n)
bool isLast;
getParagraphContext(para,isFirst,isLast);
//printf("forceStart first=%d last=%d\n",isFirst,isLast);
- if (isFirst && isLast) needsTag = FALSE;
+ if (!forced && isFirst && isLast) needsTag = FALSE;
if (needsTag)
m_t << "<p" << getDirHtmlClassOfNode(getTextDirByConfig(para, nodeIndex)) << ">";