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

Function innerText

src/html/WizGumboHelper.cpp:307–337  ·  view source on GitHub ↗

Get the inner text content of node. */

Source from the content-addressed store, hash-verified

305
306/** Get the inner text content of node. */
307QString innerText(GumboNode *node)
308{
309 if (node->type == GUMBO_NODE_TEXT) {
310 return QString(node->v.text.text);
311 }
312 else if (node->type == GUMBO_NODE_ELEMENT &&
313 node->v.element.tag != GUMBO_TAG_SCRIPT &&
314 node->v.element.tag != GUMBO_TAG_STYLE)
315 {
316 QString contents = "";
317 GumboVector *children = &node->v.element.children;
318 for (unsigned int i = 0; i < children->length; ++i) {
319 GumboNode * pNode = (GumboNode *)children->data[i];
320 std::string pTagName = get_tag_name(pNode);
321 bool is_inline = nonbreaking_inline.find("|" + pTagName + "|") != std::string::npos;
322 bool is_special_handling = special_handling.find("|" + pTagName + "|") != std::string::npos;
323 const QString text = innerText(pNode);
324 if (i != 0 && !text.isEmpty()) {
325 if (!is_inline && !is_special_handling) {
326 contents.append("\n");
327 }
328 }
329 contents.append(text);
330 }
331 return contents;
332 }
333 else
334 {
335 return QString("");
336 }
337}
338
339/** 以QTextDocument.toPlainText标准实现这个函数 */
340QString plainText(GumboNode *node)

Callers 1

WizHtmlGetContentFunction · 0.85

Calls 4

get_tag_nameFunction · 0.85
isEmptyMethod · 0.80
QStringClass · 0.50
findMethod · 0.45

Tested by

no test coverage detected