diff options
author | albert-github <albert.tests@gmail.com> | 2019-02-28 12:14:10 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2019-02-28 12:14:10 (GMT) |
commit | a735007427439b73327af0c8cfa003423bcdef6e (patch) | |
tree | 70024dc96a5e72aaa0194ec280b434b3c9c74560 /src | |
parent | 7c8994e18b57586f116ee223da9bac35b4262570 (diff) | |
download | Doxygen-a735007427439b73327af0c8cfa003423bcdef6e.zip Doxygen-a735007427439b73327af0c8cfa003423bcdef6e.tar.gz Doxygen-a735007427439b73327af0c8cfa003423bcdef6e.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/htmldocvisitor.cpp | 42 |
1 files 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 << "<object type=\"image/svg+xml\" style=\"pointer-events: none;\" data=\"" << src + m_t << "<object type=\"image/svg+xml\" data=\"" << src << "\"" << sizeAttribs << attrs; if (inlineImage) { |