From a735007427439b73327af0c8cfa003423bcdef6e Mon Sep 17 00:00:00 2001 From: albert-github Date: Thu, 28 Feb 2019 13:14:10 +0100 Subject: Multiple use of HTML attributes In case an attribute is used multiple times the XHTML validator gives (here for the style attribute): parser error : Attribute style redefined Created routine to merge these types of attributes. --- src/htmldocvisitor.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index ee8aab3..0c31dbc 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -211,6 +211,34 @@ static bool isInvisibleNode(DocNode *node) ; } +static void mergeHtmlAttributes(const HtmlAttribList &attribs, HtmlAttribList *mergeInto) +{ + HtmlAttribListIterator li(attribs); + HtmlAttrib *att; + for (li.toFirst();(att=li.current());++li) + { + HtmlAttribListIterator ml(*mergeInto); + HtmlAttrib *opt; + bool found = false; + for (ml.toFirst();(opt=ml.current());++ml) + { + if (opt->name == att -> name) + { + found = true; + break; + } + } + if (found) + { + opt->value = opt->value + " " + att->value; + } + else + { + mergeInto->append(att); + } + } +} + static QCString htmlAttribsToString(const HtmlAttribList &attribs, QCString *pAltValue = 0) { QCString result; @@ -1651,8 +1679,18 @@ void HtmlDocVisitor::visitPre(DocImage *img) sizeAttribs+=" height=\""+img->height()+"\""; } // 16 cases: url.isEmpty() | typeSVG | inlineImage | img->hasCaption() + + HtmlAttribList extraAttribs; + if (typeSVG) + { + HtmlAttrib opt; + opt.name = "style"; + opt.value = "pointer-events: none;"; + extraAttribs.append(&opt); + } QCString alt; - QCString attrs = htmlAttribsToString(img->attribs(),&alt); + mergeHtmlAttributes(img->attribs(),&extraAttribs); + QCString attrs = htmlAttribsToString(extraAttribs,&alt); QCString src; if (url.isEmpty()) { @@ -1664,7 +1702,7 @@ void HtmlDocVisitor::visitPre(DocImage *img) } if (typeSVG) { - m_t << "