MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / WizHtmlInsertText

Function WizHtmlInsertText

src/html/WizHtmlTool.cpp:53–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53QString WizHtmlInsertText(
54 const QString &htmlText,
55 const QString &text,
56 const QString &position,
57 const QString &tagName,
58 const QString &tagAttributeName /*= ""*/,
59 const QString &tagAttributeValue /*= ""*/)
60{
61 std::string rawHtmlString = htmlText.toStdString();
62 GumboOutput* output = Utils::Gumbo::parseFromString(rawHtmlString);
63
64 std::vector<GumboNode *> tags;
65 Utils::Gumbo::getElementsByTagAttr(
66 output->root, tagName, tagAttributeName, tagAttributeValue, tags);
67
68 if (tags.empty()) {
69 return htmlText;
70 }
71
72 GumboNode *firstFound = tags[0];
73 Utils::Gumbo::insertAdjacentText(firstFound, position, text, rawHtmlString);
74
75 Utils::Gumbo::destroyGumboOutput(output);
76
77 return QString::fromStdString(rawHtmlString);
78}
79
80
81/**

Callers 2

Calls 5

parseFromStringFunction · 0.85
getElementsByTagAttrFunction · 0.85
insertAdjacentTextFunction · 0.85
destroyGumboOutputFunction · 0.85
emptyMethod · 0.45

Tested by 1