Skip to content

Commit e427e3b

Browse files
committed
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 `<tbody>` is not closed. Each table level should have an own flag to signal whether or not the `<tbiody>` tag is set or not, otherwise the inner table resets the outer tables its "flag".
1 parent 3e8fe63 commit e427e3b

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/docbookvisitor.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -962,12 +962,19 @@ DB_VIS_C
962962
m_t << "</listitem></varlistentry>\n";
963963
}
964964

965+
static int tabLevel = -1;
965966
static int colCnt = 0;
966-
static bool bodySet = FALSE; // it is possible to have tables without a header
967+
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
967968
void DocbookDocVisitor::visitPre(DocHtmlTable *t)
968969
{
969970
DB_VIS_C
970-
bodySet = FALSE;
971+
static int sizeBodySet = 0;
972+
if (sizeBodySet <= ++tabLevel)
973+
{
974+
sizeBodySet += 10;
975+
bodySet = (bool *)realloc((void *)bodySet,sizeBodySet);
976+
}
977+
bodySet[tabLevel] = FALSE;
971978
if (m_hide) return;
972979
m_t << "<informaltable frame=\"all\">" << endl;
973980
m_t << " <tgroup cols=\"" << t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
@@ -982,8 +989,8 @@ void DocbookDocVisitor::visitPost(DocHtmlTable *)
982989
{
983990
DB_VIS_C
984991
if (m_hide) return;
985-
if (bodySet) m_t << " </tbody>" << endl;
986-
bodySet = FALSE;
992+
if (bodySet[tabLevel--]) m_t << " </tbody>" << endl;
993+
//bodySet = FALSE;
987994
m_t << " </tgroup>" << endl;
988995
m_t << "</informaltable>" << endl;
989996
}
@@ -994,10 +1001,15 @@ DB_VIS_C
9941001
colCnt = 0;
9951002
if (m_hide) return;
9961003

997-
if (tr->isHeading()) m_t << "<thead>\n";
998-
else if (!bodySet)
1004+
if (tr->isHeading())
1005+
{
1006+
if (bodySet[tabLevel]) m_t << "</tbody>\n";
1007+
bodySet[tabLevel] = FALSE;
1008+
m_t << "<thead>\n";
1009+
}
1010+
else if (!bodySet[tabLevel])
9991011
{
1000-
bodySet = TRUE;
1012+
bodySet[tabLevel] = TRUE;
10011013
m_t << "<tbody>\n";
10021014
}
10031015

@@ -1038,7 +1050,7 @@ DB_VIS_C
10381050
m_t << "</row>\n";
10391051
if (tr->isHeading())
10401052
{
1041-
bodySet = TRUE;
1053+
bodySet[tabLevel] = TRUE;
10421054
m_t << "</thead><tbody>\n";
10431055
}
10441056
}

0 commit comments

Comments
 (0)