From d33a129d784f2b0f823f14a008e929513b302ad3 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 2 Dec 2018 18:40:28 +0100 Subject: Fixed incorrect XHTML output for test 021 --- src/htmldocvisitor.cpp | 83 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index dfa6089..2223ed9 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -134,6 +134,7 @@ static bool mustBeOutsideParagraph(DocNode *n) case DocNode::Kind_HtmlBlockQuote: /* \parblock */ case DocNode::Kind_ParBlock: + case DocNode::Kind_IncOperator: return TRUE; case DocNode::Kind_Verbatim: { @@ -152,6 +153,57 @@ static bool mustBeOutsideParagraph(DocNode *n) return FALSE; } +static bool isDocVerbatimVisible(DocVerbatim *s) +{ + switch(s->type()) + { + case DocVerbatim::ManOnly: + case DocVerbatim::LatexOnly: + case DocVerbatim::XmlOnly: + case DocVerbatim::RtfOnly: + case DocVerbatim::DocbookOnly: + return FALSE; + default: + return TRUE; + } +} + +static bool isDocIncludeVisible(DocInclude *s) +{ + switch (s->type()) + { + case DocInclude::DontInclude: + return FALSE; + default: + return TRUE; + } +} + +static bool isDocIncOperatorVisible(DocIncOperator *s) +{ + switch (s->type()) + { + case DocIncOperator::Skip: + return FALSE; + default: + return TRUE; + } +} + +static bool isInvisibleNode(DocNode *node) +{ + return (node->kind()==DocNode::Kind_WhiteSpace) + || // skip over image nodes that are not for HTML output + (node->kind()==DocNode::Kind_Image && ((DocImage*)node)->type()!=DocImage::Html) + || // skip over verbatim nodes that are not visible in the HTML output + (node->kind()==DocNode::Kind_Verbatim && !isDocVerbatimVisible((DocVerbatim*)node)) + || // skip over include nodes that are not visible in the HTML output + (node->kind()==DocNode::Kind_Include && !isDocIncludeVisible((DocInclude*)node)) + || // skip over include operator nodes that are not visible in the HTML output + (node->kind()==DocNode::Kind_IncOperator && !isDocIncOperatorVisible((DocIncOperator*)node)) + ; +} + static QString htmlAttribsToString(const HtmlAttribList &attribs, bool img_tag = FALSE) { QString result; @@ -679,7 +731,7 @@ void HtmlDocVisitor::visit(DocIncOperator *op) // op->type(),op->isFirst(),op->isLast(),op->text().data()); if (op->isFirst()) { - forceStartParagraph(op); + forceEndParagraph(op); if (!m_hide) m_t << PREFRAG_START; pushEnabled(); m_hide=TRUE; @@ -1108,8 +1160,7 @@ void HtmlDocVisitor::visitPre(DocPara *p) uint nodeIndex = 0; if (p && nodeIndexchildren().count()) { - while (nodeIndexchildren().count() && - p->children().at(nodeIndex)->kind()==DocNode::Kind_WhiteSpace) + while (nodeIndexchildren().count() && isInvisibleNode(p->children().at(nodeIndex))) { nodeIndex++; } @@ -1177,7 +1228,7 @@ void HtmlDocVisitor::visitPost(DocPara *p) int nodeIndex = p->children().count()-1; if (nodeIndex>=0) { - while (nodeIndex>=0 && p->children().at(nodeIndex)->kind()==DocNode::Kind_WhiteSpace) + while (nodeIndex>=0 && isInvisibleNode(p->children().at(nodeIndex))) { nodeIndex--; } @@ -2277,30 +2328,6 @@ static bool insideStyleChangeThatIsOutsideParagraph(DocPara *para,int nodeIndex) return styleOutsideParagraph; } -static bool isDocVerbatimVisible(DocVerbatim *s) -{ - switch(s->type()) - { - case DocVerbatim::ManOnly: - case DocVerbatim::LatexOnly: - case DocVerbatim::XmlOnly: - case DocVerbatim::RtfOnly: - case DocVerbatim::DocbookOnly: - return FALSE; - default: - return TRUE; - } -} - -static bool isInvisibleNode(DocNode *node) -{ - return (node->kind()==DocNode::Kind_WhiteSpace) || - // skip over image nodes that are not for HTML output - (node->kind()==DocNode::Kind_Image && ((DocImage*)node)->type()!=DocImage::Html) || - // skip over verbatim nodes that are not visible in the HTML output - (node->kind()==DocNode::Kind_Verbatim && !isDocVerbatimVisible((DocVerbatim*)node)); -} - /** Used for items found inside a paragraph, which due to XHTML restrictions * have to be outside of the paragraph. This method will forcefully end * the current paragraph and forceStartParagraph() will restart it. -- cgit v0.12