Creates a new Node (of the same type as the original node) that
is similar to the orginal but doesn't contain any empty text or
CDATA nodes and where all textual content including attribute
values or comments are trimmed.
357879
public static Node stripWhitespace(Node original) {
        Node cloned = original.cloneNode(true);
        cloned.normalize();
        handleWsRec(cloned, false);
        return cloned;
    }
568862
function createEmptyContent(opts: Options): Block {
    return Block.create({
        type: opts.typeContent,
        nodes: [Text.create()]
    });
}
1272891
def createNode(self, cls, name, *args, **kw):
        
        m = self.findNode(name)
        if m is None:
            m = cls(name, *args, **kw)
            self.addNode(m)
        return m
715419
def dnode(self, node):
        """"""
        new_node = copy(node)
        new_node.lineno += self.dline
        new_node.col_offset += self.dcol
        return new_node
789679
function insertContent(node, content) {
	let inserted = insertContentIntoPlaceholder(node, content);
	node.walk(child => inserted |= insertContentIntoPlaceholder(child, content));

	if (!inserted) {
		// no placeholders were found in node, insert content into deepest child
		setNodeContent(findDeepestNode(node), content);
	}

	return node;
}
1157398
def makeNodeTuple(citation, idVal, nodeInfo, fullInfo, nodeType, count, coreCitesDict, coreValues, detailedValues, addCR):
    """"""
    d = {}
    if nodeInfo:
        if nodeType == 'full':
            if coreValues:
                if citation in coreCitesDict:
                    R = coreCitesDict[citation]
                    d['MK-ID'] = R.id
                    if not detailedValues:
                        infoVals = []
                        for tag in coreValues:
                            tagVal = R.get(tag)
                            if isinstance(tagVal, str):
                                infoVals.append(tagVal.replace(',',''))
                            elif isinstance(tagVal, list):
                                infoVals.append(tagVal[0].replace(',',''))
                            else:
                                pass
                        d['info'] = ', '.join(infoVals)
                    else:
                        for tag in coreValues:
                            v = R.get(tag, None)
                            if isinstance(v, list):
                                d[tag] = '|'.join(sorted(v))
                            else:
                                d[tag] = v
                    d['inCore'] = True
                    if addCR:
                        d['citations'] = '|'.join((str(c) for c in R.get('citations', [])))
                else:
                    d['MK-ID'] = 'None'
                    d['info'] = citation.allButDOI()
                    d['inCore'] = False
                    if addCR:
                        d['citations'] = ''
            else:
                d['info'] = citation.allButDOI()
        elif nodeType == 'journal':
            if citation.isJournal():
                d['info'] = str(citation.FullJournalName())
            else:
                d['info'] = "None"
        elif nodeType == 'original':
            d['info'] = str(citation)
        else:
            d['info'] = idVal
    if fullInfo:
        d['fullCite'] = str(citation)
    if count:
        d['count'] = 1
    return (idVal, d)
710875
function extractTextContent (node) {
    var buf = []
    var textContent
    
    switch (node.nodeType) {
      case 1: // Element node such as <p> or <div>
      case 11: // A DocumentFragment node ( a minimal document object that has no parent)
        node = node.firstChild
        while (node) {
          // Type 7 = a ProcessingInstruction of an XML document such as <?xml-stylesheet ... ?> declaration
          // Type 8 = a Comment node
          if (node.nodeType !== 7 && node.nodeType !== 8) {
            textContent = extractTextContent(node)
            
            if (textContent.length > 0 && buf.length > 0) {
              var previousTextContent = buf[buf.length - 1]
              
              if (textContent[0] !== ' ' && previousTextContent.length > 0 && previousTextContent[previousTextContent.length - 1] !== ' ') {
                buf.push(' ')
              }
            }
            
            buf.push(textContent)
          }
          node = node.nextSibling
        }
        return buf.join('')
      default:
        return node.nodeValue
    }
  }
92978
def newDocRawNode(self, doc, name, content):
        
        if doc is None: doc__o = None
        else: doc__o = doc._o
        ret = libxml2mod.xmlNewDocRawNode(doc__o, self._o, name, content)
        if ret is None:raise treeError('xmlNewDocRawNode() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
1137308
def newCDataBlock(self, content, len):
        
        ret = libxml2mod.xmlNewCDataBlock(self._o, content, len)
        if ret is None:raise treeError('xmlNewCDataBlock() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
511133
function(html) {

      var x, newNode, node, firstChild;

      // create a new node
      newNode = document.createElement('div');
      newNode.innerHTML = html;

      // get new new node
      newNode = newNode.childNodes[0];
      newNode.setAttribute('hashedit-element', '');

      hashedit.setupElementMenu(newNode);

      // get existing node
      node = document.querySelector('[hashedit-sortable] [data-selector]');

      if (node === null) {

        if (hashedit.current.node !== null) {

          // insert after current node
          hashedit.current.node.parentNode.insertBefore(newNode, hashedit.current.node.nextSibling);

        }

      }
      else {
        // replace existing node with newNode
        node.parentNode.replaceChild(newNode, node);
      }

      var types = 'p, h1, h2, h3, h4, h5, li, td, th, blockquote, pre';

      // set editable children
      var editable = newNode.querySelectorAll(types);

      for (x = 0; x < editable.length; x += 1) {
        editable[x].setAttribute('contentEditable', 'true');
      }

      if (types.indexOf(newNode.nodeName.toLowerCase()) != -1) {
        newNode.setAttribute('contentEditable', 'true');
      }

      // select element
      function selectElementContents(el) {
        var range = document.createRange();
        range.selectNodeContents(el);
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
      }

      // focus on first element
      if (editable.length > 0) {

        editable[0].focus();
        selectElementContents(editable[0]);

        // show edit options for the text
        hashedit.showTextOptions(editable[0]);

        // select editable contents, #ref: http://bit.ly/1jxd8er
        hashedit.selectElementContents(editable[0]);
      }
      else {

        if(newNode.matches(types)) {

          newNode.focus();
          selectElementContents(newNode);

        }

      }

      return newNode;

    }
1075324
function (elem)
    {
        var i, el;
        if (elem.nodeType == Strophe.ElementType.NORMAL) {
            el = Strophe.xmlElement(elem.tagName);

            for (i = 0; i < elem.attributes.length; i++) {
                el.setAttribute(elem.attributes[i].nodeName,
                                elem.attributes[i].value);
            }

            for (i = 0; i < elem.childNodes.length; i++) {
                el.appendChild(Strophe.copyElement(elem.childNodes[i]));
            }
        } else if (elem.nodeType == Strophe.ElementType.TEXT) {
            el = Strophe.xmlGenerator().createTextNode(elem.nodeValue);
        }

        return el;
    }
277438
function createNodes(entityRanges, decoratorRanges = [], textArray, block) {
  let lastIndex = 0;
  const mergedRanges = [...entityRanges, ...decoratorRanges].sort((a, b) => a.offset - b.offset);
  const nodes = [];
  // if thers no entities will return just a single item
  if (mergedRanges.length < 1) {
    nodes.push(new ContentNode({ block, start: 0, end: textArray.length }));
    return nodes;
  }

  mergedRanges.forEach((range) => {
    // create an empty node for content between previous and this entity
    if (range.offset > lastIndex) {
      nodes.push(new ContentNode({ block, start: lastIndex, end: range.offset }));
    }
    // push the node for the entity
    nodes.push(new ContentNode({
      block,
      entity: range.key,
      decorator: range.component,
      decoratorProps: range.decoratorProps,
      decoratedText: range.component
        ? getString(textArray, range.offset, range.offset + range.length)
        : undefined,
      start: range.offset,
      end: range.offset + range.length,
      contentState: range.contentState,
    }));
    lastIndex = range.offset + range.length;
  });

  // finaly add a node for the remaining text if any
  if (lastIndex < textArray.length) {
    nodes.push(new ContentNode({
      block,
      start: lastIndex,
      end: textArray.length,
    }));
  }
  return nodes;
}
1014022
public Node<T> node(T content) {
    final Node<T> search = nodes.get(content);
    if (search != null)
      return search;
    final Node<T> n = new Node<>(content, this);
    nodes.put(content, n);
    return n;
  }
680595
function(node) {
        var data;
        if(this.xmldom) {
            data = node.xml;
        } else {
            var serializer = new XMLSerializer();
            if (node.nodeType == 1) {
                // Add nodes to a document before serializing. Everything else
                // is serialized as is. This may need more work. See #1218 .
                var doc = document.implementation.createDocument("", "", null);
                if (doc.importNode) {
                    node = doc.importNode(node, true);
                }
                doc.appendChild(node);
                data = serializer.serializeToString(doc);
            } else {
                data = serializer.serializeToString(node);
            }
        }
        return data;
    }
1283146
public static Text createTextNode(String value)
   {
      Document doc = getOwnerDocument();
      return doc.createTextNode(value);
   }
717480
def copy_node(node):
    """"""
    element = node.makeelement(node.tag)
    element.text = node.text
    element.tail = node.tail
    for key, value in node.items():
        element.set(key, value)

    return element
1303238
def _ensure_node(node: Union[str, AbstractNode]) -> AbstractNode:
    
    if isinstance(node, str):
        return Text(node)
    elif isinstance(node, Node):
        return node
    else:
        raise TypeError('Invalid type to append: {}'.format(node))