Doxygen
Loading...
Searching...
No Matches
HtmlAttribList Class Referencefinal

Class representing a list of HTML attributes. More...

#include <src/htmlattrib.h>

Inheritance diagram for HtmlAttribList:
Collaboration diagram for HtmlAttribList:

Public Member Functions

void mergeAttribute (const DString &optName, const DString &optValue)
DString toString (DString *pAltValue=nullptr) const

Detailed Description

Class representing a list of HTML attributes.

Definition at line 30 of file htmlattrib.h.

Member Function Documentation

◆ mergeAttribute()

void HtmlAttribList::mergeAttribute ( const DString & optName,
const DString & optValue )
inline

Definition at line 33 of file htmlattrib.h.

34 {
35 auto it = std::find_if(begin(),end(),
36 [&optName](const auto &opt) { return opt.name==optName; });
37 if (it!=end()) // attribute name already in the list: append values
38 {
39 it->value += " " + optValue;
40 }
41 else // attribute name not yet in the list
42 {
43 emplace_back(optName,optValue);
44 }
45 }
DirIterator begin(DirIterator it) noexcept
Definition dir.cpp:171
DirIterator end(const DirIterator &) noexcept
Definition dir.cpp:176

References begin(), and end().

Referenced by HtmlDocVisitor::operator()().

◆ toString()

DString HtmlAttribList::toString ( DString * pAltValue = nullptr) const
inline

Definition at line 47 of file htmlattrib.h.

48 {
49 DString result;
50 for (const auto &att : *this)
51 {
52 if (!att.value.empty()) // ignore attribute without values as they
53 // are not XHTML compliant, with the exception
54 // of the alt attribute with the img tag
55 {
56 if (att.name=="alt" && pAltValue) // optionally return the value of alt separately
57 // need to convert <img> to <object> for SVG images,
58 // which do not support the alt attribute
59 {
60 *pAltValue = att.value;
61 }
62 else
63 {
64 result+=" "+att.name+"=\""+convertToXML(att.value)+"\"";
65 }
66 }
67 else if (att.name=="open")
68 {
69 // The open attribute is a boolean attribute.
70 // Specifies that the details should be visible (open) to the user
71 // As it is a boolean attribute the initialization value is of no interest
72 result+=" "+att.name+"=\"true\"";
73 }
74 else if (att.name=="nowrap") // In XHTML, attribute minimization is forbidden, and the nowrap attribute must be defined as <td nowrap="nowrap">.
75 {
76 result+=" "+att.name+"=\"nowrap\"";
77 }
78 }
79 return result;
80 }
DString convertToXML(const DString &s, bool keepEntities, const bool citeEntry)
Definition util.cpp:3234

References convertToXML().

Referenced by HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), and HtmlDocVisitor::operator()().


The documentation for this class was generated from the following file: