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

Function insertAdjacentText

src/html/WizGumboHelper.cpp:436–466  ·  view source on GitHub ↗

* @brief Insert plain text or html text to original html string. * * @param node * @param position See https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentText * @param text * @param originalHtml * @return QString */

Source from the content-addressed store, hash-verified

434 * @return QString
435 */
436void insertAdjacentText(GumboNode *node, const QString &position, const QString &text, std::string &originalHtml)
437{
438 if (node->type != GUMBO_NODE_ELEMENT) {
439 return;
440 }
441
442 GumboElement *elem = &node->v.element;
443 size_t pos = 0;
444 if (position == "beforebegin")
445 {
446 pos = elem->start_pos.offset;
447 }
448 else if (position == "afterbegin")
449 {
450 pos = elem->start_pos.offset + elem->original_tag.length;
451 }
452 else if (position == "beforeend")
453 {
454 pos = elem->end_pos.offset;
455 }
456 else if (position == "afterend")
457 {
458 pos = elem->end_pos.offset + elem->original_end_tag.length;
459 }
460 else
461 {
462 return;
463 }
464
465 originalHtml.insert(pos, text.toStdString());
466}
467
468
469void filterTagsByAttribute(

Callers 1

WizHtmlInsertTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected