diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-02-02 12:56:57 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-02-02 13:01:40 (GMT) |
commit | 90fb3132ce02eb44abe3797954267fefcb8d10a8 (patch) | |
tree | 82488a1c3d2465d3c50d3aa9c65f7652a585797e | |
parent | a2954444b3b2bd0af09f3c886f13b4597866153a (diff) | |
download | Doxygen-90fb3132ce02eb44abe3797954267fefcb8d10a8.zip Doxygen-90fb3132ce02eb44abe3797954267fefcb8d10a8.tar.gz Doxygen-90fb3132ce02eb44abe3797954267fefcb8d10a8.tar.bz2 |
Avoid unsupported html attributes from appearing in the XML/docbook output and other small fixes
-rw-r--r-- | src/docbookvisitor.cpp | 97 | ||||
-rw-r--r-- | src/xmldocvisitor.cpp | 57 | ||||
-rw-r--r-- | templates/html/doxygen.css | 41 | ||||
-rw-r--r-- | templates/xml/compound.xsd | 12 |
4 files changed, 75 insertions, 132 deletions
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 8bb5a34..4b4de4a 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -69,6 +69,21 @@ static QCString filterId(const char *s) return growBuf.get(); } +static bool supportedHtmlAttribute(const QCString &name) +{ + return (name=="align" || + name=="bgcolor" || + name=="border" || + name=="cellpadding" || + name=="cellspacing" || + name=="class" || + name=="frame" || + name=="label" || + name=="tabstyle" || + name=="title"); +} + + void DocbookDocVisitor::visitCaption(const QList<DocNode> &children) { QListIterator<DocNode> cli(children); @@ -1034,25 +1049,10 @@ DB_VIS_C HtmlAttrib *opt; for (li.toFirst();(opt=li.current());++li) { - if (opt->name=="class") - { - // just skip it - } - else if (opt->name=="style") - { - // just skip it - } - else if (opt->name=="height") - { - // just skip it - } - else if (opt->name=="filter") + if (supportedHtmlAttribute(opt->name)) { - // just skip it - } - else - { - m_t << " " << opt->name << "='" << opt->value << "'"; + // process supported attributes only + m_t << " " << opt->name << "='" << convertToDocBook(opt->value) << "'"; } } m_t << ">\n"; @@ -1095,54 +1095,31 @@ DB_VIS_C } else if (opt->name=="class") { - if (opt->value == "markdownTableBodyRight") + if (opt->value.left(13)=="markdownTable") // handle markdown generated attributes { - m_t << " align='right'"; - } - else if (opt->value == "markdownTableBodyLeftt") - { - m_t << " align='left'"; - } - else if (opt->value == "markdownTableBodyCenter") - { - m_t << " align='center'"; - } - else if (opt->value == "markdownTableHeadRight") - { - m_t << " align='right'"; - } - else if (opt->value == "markdownTableHeadLeftt") - { - m_t << " align='left'"; - } - else if (opt->value == "markdownTableHeadCenter") - { - m_t << " align='center'"; + if (opt->value.right(5)=="Right") + { + m_t << " align='right'"; + } + else if (opt->value.right(4)=="Left") + { + m_t << " align='left'"; + } + else if (opt->value.right(6)=="Center") + { + m_t << " align='center'"; + } + // skip 'markdownTable*' value ending with "None" } - else if (!opt->value.isEmpty()) + else { - m_t << " " << opt->name << "='" << opt->value << "'"; + m_t << " class='" << convertToDocBook(opt->value) << "'"; } } - else if (opt->name=="style") - { - // just skip it - } - else if (opt->name=="width") - { - // just skip it - } - else if (opt->name=="height") - { - // just skip it - } - else if (opt->name=="nowrap" && opt->value.isEmpty()) - { - m_t << " " << opt->name << "='nowrap'"; - } - else + else if (supportedHtmlAttribute(opt->name)) { - m_t << " " << opt->name << "='" << opt->value << "'"; + // process supported attributes only + m_t << " " << opt->name << "='" << convertToDocBook(opt->value) << "'"; } } m_t << ">"; diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index 0d1c740..31eeb16 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -811,44 +811,41 @@ void XmlDocVisitor::visitPre(DocHtmlCell *c) HtmlAttrib *opt; for (li.toFirst();(opt=li.current());++li) { - if (opt->name=="class") + if (opt->name=="colspan" || opt->name=="rowspan") { - if (opt->value == "markdownTableBodyRight") - { - m_t << " align=\"right\""; - } - else if (opt->value == "markdownTableBodyLeftt") - { - m_t << " align=\"left\""; - } - else if (opt->value == "markdownTableBodyCenter") - { - m_t << " align=\"center\""; - } - else if (opt->value == "markdownTableHeadRight") - { - m_t << " align=\"right\""; - } - else if (opt->value == "markdownTableHeadLeftt") - { - m_t << " align=\"left\""; - } - else if (opt->value == "markdownTableHeadCenter") + m_t << " " << opt->name << "=\"" << opt->value.toInt() << "\""; + } + else if (opt->name=="align" && + (opt->value=="right" || opt->value=="left" || opt->value=="center")) + { + m_t << " align=\"" << opt->value << "\""; + } + else if (opt->name=="class") // handle markdown generated attributes + { + if (opt->value.left(13)=="markdownTable") // handle markdown generated attributes { - m_t << " align=\"center\""; + if (opt->value.right(5)=="Right") + { + m_t << " align='right'"; + } + else if (opt->value.right(4)=="Left") + { + m_t << " align='left'"; + } + else if (opt->value.right(6)=="Center") + { + m_t << " align='center'"; + } + // skip 'markdownTable*' value ending with "None" } else if (!opt->value.isEmpty()) { - m_t << " " << opt->name << "=\"" << opt->value << "\""; + m_t << " class=\"" << convertToXML(opt->value) << "\""; } } - else if (opt->name=="nowrap" && opt->value.isEmpty()) - { - m_t << " " << opt->name << "=\"nowrap\""; - } - else if (!opt->value.isEmpty()) + else if (!opt->name.isEmpty() && !opt->value.isEmpty()) // dump generic html attribute { - m_t << " " << opt->name << "=\"" << opt->value << "\""; + m_t << " htmlattrib=\"" << convertToXML(opt->name) << "=" << convertToXML(opt->value) << "\""; } } m_t << ">"; diff --git a/templates/html/doxygen.css b/templates/html/doxygen.css index 2c9dfd5..8f2c213 100644 --- a/templates/html/doxygen.css +++ b/templates/html/doxygen.css @@ -1661,47 +1661,6 @@ tr.heading h2 { /* @group Markdown */ -/* -table.markdownTable { - border-collapse:collapse; - margin-top: 4px; - margin-bottom: 4px; -} - -table.markdownTable td, table.markdownTable th { - border: 1px solid ##37; - padding: 3px 7px 2px; -} - -table.markdownTableHead tr { -} - -table.markdownTableBodyLeft td, table.markdownTable th { - border: 1px solid ##37; - padding: 3px 7px 2px; -} - -th.markdownTableHeadLeft th.markdownTableHeadRight th.markdownTableHeadCenter th.markdownTableHeadNone { - background-color: ##47; - color: ##ff; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; -} - -th.markdownTableHeadLeft { - text-align: left -} - -th.markdownTableHeadRight { - text-align: right -} - -th.markdownTableHeadCenter { - text-align: center -} -*/ - table.markdownTable { border-collapse:collapse; margin-top: 4px; diff --git a/templates/xml/compound.xsd b/templates/xml/compound.xsd index 191527f..277a584 100644 --- a/templates/xml/compound.xsd +++ b/templates/xml/compound.xsd @@ -572,7 +572,9 @@ <xsd:attribute name="thead" type="DoxBool" /> <xsd:attribute name="colspan" type="xsd:integer" /> <xsd:attribute name="rowspan" type="xsd:integer" /> - <!-- maybe other attributes can be listed as well --> + <xsd:attribute name="align" type="DoxAlign" /> + <xsd:attribute name="class" type="xsd:string" /> + <xsd:attribute name="htmlattrib" type="xsd:string" /> <xsd:anyAttribute processContents="skip"/> </xsd:complexType> @@ -940,5 +942,13 @@ </xsd:restriction> </xsd:simpleType> + <xsd:simpleType name="DoxAlign"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="left"/> + <xsd:enumeration value="right"/> + <xsd:enumeration value="center"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:schema> |