create paragraph node from TxtNodes
@param {[TxtNode]} nodes
@returns {TxtNode} Paragraph node
11393
function createParagraph(nodes) {
    const firstNode = nodes[0];
    const lastNode = nodes[nodes.length - 1];
    return {
        type: Syntax.Paragraph,
        raw: nodes
            .map(function(node) {
                return node.raw;
            })
            .join(""),
        range: [firstNode.range[0], lastNode.range[1]],
        loc: {
            start: {
                line: firstNode.loc.start.line,
                column: firstNode.loc.start.column
            },
            end: {
                line: lastNode.loc.end.line,
                column: lastNode.loc.end.column
            }
        },
        children: nodes
    };
}
469872
function wrap(nodes, loose) {
  var result = []
  var index = -1
  var length = nodes.length

  if (loose) {
    result.push(u('text', '\n'))
  }

  while (++index < length) {
    if (index) {
      result.push(u('text', '\n'))
    }

    result.push(nodes[index])
  }

  if (loose && nodes.length !== 0) {
    result.push(u('text', '\n'))
  }

  return result
}
675240
def merge_text_nodes_on(self, node):
        """"""

        if not isinstance(node, ContainerNode) or not node.children:
            return

        new_children = []
        text_run = []
        for i in node.children:
            if isinstance(i, Text) and not i.translatable:
                text_run.append(i.escaped())
            else:
                if text_run:
                    new_children.append(EscapedText(''.join(text_run)))
                    text_run = []

                new_children.append(i)

        if text_run:
            new_children.append(EscapedText(''.join(text_run)))

        node.children = new_children
        for i in node.children:
            self.merge_text_nodes_on(i)
1335685
function split_lines_by_child_nodes(lines)
{
	// determine lines with indentation = 0 (child node entry lines)
	const node_entry_lines = lines.map((line, index) => 
	{
		return { tabs: line.tabs, index }
	})
	.filter(line => line.tabs === 0)
	.map(line => line.index)

	// deduce corresponding child node ending lines
	const node_ending_lines = node_entry_lines.map(line_index => line_index - 1)
	node_ending_lines.shift()
	node_ending_lines.push(lines.length - 1)

	// each child node boundaries in terms of starting line index and ending line index
	const from_to = zip(node_entry_lines, node_ending_lines)

	// now lines are split by child nodes
	return from_to.map(from_to => lines.slice(from_to[0], from_to[1] + 1))
}
1351083
function Node (config) {
    RED.nodes.createNode(this, config);
    var node = this;

    this.on('input', function (msg) {
      var method = config['tts-custom-mode'],
        message = '',
        params = {};

      username = sUsername || this.credentials.username;
      password = sPassword || this.credentials.password || config.password;
      apikey = sApikey || this.credentials.apikey || config.apikey;

      endpoint = sEndpoint;
      if ((!config['default-endpoint']) && config['service-endpoint']) {
        endpoint = config['service-endpoint'];
      }

      if (!apikey && (!username || !password)) {
        message = 'Missing Watson Text to Speech service credentials';
      } else if (!method || '' === method) {
        message = 'Required mode has not been specified';
      } else {
        params = buildParams(msg, method, config);
      }

      if (message) {
        payloadutils.reportError(node, msg, message);
        return;
      }

      if (checkForFile(method)) {
        if (msg.payload instanceof Buffer) {
          loadFile(node, method, params, msg);
          return;
        }
        params = setFileParams(method, params, msg);
      }

      executeMethod(node, method, params, msg);
    });
  }
1042776
function fixParagraphNode(node, fullText) {
    const firstNode = node.children[0];
    const lastNode = node.children[node.children.length - 1];
    node.range = [firstNode.range[0], lastNode.range[1]];
    node.raw = fullText.slice(node.range[0], node.range[1]);
    node.loc = {
        start: {
            line: firstNode.loc.start.line,
            column: firstNode.loc.start.column
        },
        end: {
            line: lastNode.loc.end.line,
            column: lastNode.loc.end.column
        }
    };
}
1326754
function text (factory, node, cursor) {
    // Process a text node. 
    var parentNode = node.parentNode;

    // If the node is CDATA convert it to text.
    if (node.nodeType == 4) {
      var text = factory.createTextNode(node.data);
      parentNode.insertBefore(text, node);
      parentNode.removeChild(node);
      node = text;
    }

    var prev = node.previousSibling;
    if (node.nodeType == 3) {
      // Combine adjacent text nodes. You'll notice that this means that we
      // might be reaching outside the range givne to us to normalize. That is
      // if fine. The boundary is guidance to save time, not a firewall.
      if (prev != null && prev.nodeType == 3) {
        var text = factory.createTextNode(prev.data + node.data);
        if (prev == cursor.node) {
          cursor.node = text;
        }
        parentNode.insertBefore(text, prev);
        parentNode.removeChild(prev);
        parentNode.removeChild(node);
        node = text;
      }

      // Remove duplicate whitespace.
      if (/\s\s/.test(node.data)) {
        var text = factory.createTextNode(node.data.replace(/\s\s+/g, " "));
        parentNode.insertBefore(text, node);
        parentNode.removeChild(node);
        node = text;
      }
    }

    return node;
  }
483326
function createText(value, data) {
  const node = { object: 'text', data };
  const leaves = isArray(value) ? value : [{ text: value }];
  return { ...node, leaves };
}
1308593
function getBrackets() {
  const type = NodeType.BracketsType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const right = token.right;
  let content = [];

  // Skip `[`.
  pos++;

  if (pos < right) {
    content = getTsets();
  }

  const end = getLastPosition(content, line, column, 1);

  // Skip `]`.
  pos++;

  return newNode(type, content, line, column, end);
}
225535
function parseTopLevelNodes() {
      var acorn = require('acorn');
      var output = acorn.parse(source, {
        locations: true,
        sourceFile: filePath,
        onComment: onComment
      });

      namespaceBoundary();

      output.body.forEach(function(node) {
        processTopLevelNode(node);
      });
    }
635355
function questionBlock(nodes) {
    return nodes.slice(
        nodes[0].type === 'paragraph' ? 1 : 0,
        _.findIndex(nodes, { type: 'blockquote_start' })
    );
}
982764
def leaf_div_elements_into_paragraphs(document):
    
    for element in document.iter(tag="div"):
        child_tags = tuple(n.tag for n in element.getchildren())
        if "div" not in child_tags and "p" not in child_tags:
            logger.debug(
                "Changing leaf block element <%s> into <p>", element.tag)
            element.tag = "p"

    return document
1267498
function tagNodesWithIds (data) {
  let id = 0
  const idsToNodes = new Map()
  const nodesToIds = new Map()
  tagNodes(data)

  return {
    idsToNodes,
    nodesToIds
  }

  function tag (node) {
    idsToNodes.set(id, node)
    nodesToIds.set(node, id)
    id++
  }
  function tagNodes (node) {
    tag(node)
    if (node.children) node.children.forEach(tagNodes)
  }
}
458708
function createNode(src, raw, files, config) {
  var node = new FilesNode(src, raw, config);
  if (node.path || node.src) {
    files.push(node);
  }
}
176547
def paragraph(node):
    
    text = ''
    if node.string_content is not None:
        text = node.string_content
    o = nodes.paragraph('', ' '.join(text))
    o.line = node.sourcepos[0][0]
    for n in MarkDown(node):
        o.append(n)

    return o
923634
function (nodes) {
    var n = pickLinear(nodes);
    while (nodes.length > 0) {
      pickNext(nodes, n[0], n[1]);
    }
    return n;
  }
734274
function flattenNodes(nodes) {
	return nodes.reduce((acc, item) => {
		if (item.nodes) acc.push(...flattenNodes(item.nodes))
		else acc.push(item);
		return acc;
	}, []);
}