MCPcopy Create free account
hub / github.com/Sigil-Ebook/Sigil / GetLanguageAttribute

Method GetLanguageAttribute

src/ResourceObjects/HTMLResource.cpp:213–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213QString HTMLResource::GetLanguageAttribute()
214{
215 GumboInterface gi = GumboInterface(GetText(),GetEpubVersion());
216 gi.parse();
217 QList<GumboNode*> htmltags = gi.get_all_nodes_with_tag(GUMBO_TAG_HTML);
218 if (htmltags.count() != 1) return "";
219 GumboNode* node = htmltags.at(0);
220 QString lang="";
221 GumboAttribute* attr = gumbo_get_attribute(&node->v.element.attributes, "xml:lang");
222 if (attr) {
223 lang = QString::fromUtf8(attr->value);
224 return lang;
225 }
226 attr = gumbo_get_attribute(&node->v.element.attributes, "lang");
227 if (attr) {
228 lang = QString::fromUtf8(attr->value);
229 }
230 return lang;
231}
232
233void HTMLResource::SetLanguageAttribute(const QString& langcode)
234{

Callers 2

InsertClipMethod · 0.80
foreachFunction · 0.80

Calls 4

GumboInterfaceClass · 0.85
gumbo_get_attributeFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected