From e427e3b1e2a03af6d87b7d46996aabafde454bcc Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 12 Aug 2019 15:10:13 +0200 Subject: Opening and ending tag mismatch: tbody in docbook output In case of docbook output and having nesting tables (e.g. in the tables chapter of the doxygen documentation), we get invalid xml for docbook as the `` is not closed. Each table level should have an own flag to signal whether or not the `` tag is set or not, otherwise the inner table resets the outer tables its "flag". --- src/docbookvisitor.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index ce3a845..47c0121 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -962,12 +962,19 @@ DB_VIS_C m_t << "\n"; } +static int tabLevel = -1; static int colCnt = 0; -static bool bodySet = FALSE; // it is possible to have tables without a header +static bool *bodySet = NULL; // it is possible to have tables without a header, needs to be an array as we can have tables in tables void DocbookDocVisitor::visitPre(DocHtmlTable *t) { DB_VIS_C - bodySet = FALSE; + static int sizeBodySet = 0; + if (sizeBodySet <= ++tabLevel) + { + sizeBodySet += 10; + bodySet = (bool *)realloc((void *)bodySet,sizeBodySet); + } + bodySet[tabLevel] = FALSE; if (m_hide) return; m_t << "" << endl; m_t << " numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; @@ -982,8 +989,8 @@ void DocbookDocVisitor::visitPost(DocHtmlTable *) { DB_VIS_C if (m_hide) return; - if (bodySet) m_t << " " << endl; - bodySet = FALSE; + if (bodySet[tabLevel--]) m_t << " " << endl; + //bodySet = FALSE; m_t << " " << endl; m_t << "" << endl; } @@ -994,10 +1001,15 @@ DB_VIS_C colCnt = 0; if (m_hide) return; - if (tr->isHeading()) m_t << "\n"; - else if (!bodySet) + if (tr->isHeading()) + { + if (bodySet[tabLevel]) m_t << "\n"; + bodySet[tabLevel] = FALSE; + m_t << "\n"; + } + else if (!bodySet[tabLevel]) { - bodySet = TRUE; + bodySet[tabLevel] = TRUE; m_t << "\n"; } @@ -1038,7 +1050,7 @@ DB_VIS_C m_t << "\n"; if (tr->isHeading()) { - bodySet = TRUE; + bodySet[tabLevel] = TRUE; m_t << "\n"; } } -- cgit v0.12