How to use unist-util-remove - 5 common examples

To help you get started, we’ve selected a few unist-util-remove examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Enalean / tuleap / plugins / testmanagement / scripts / testmanagement / src / execution / truncate.js View on Github external
}

        if (counter + node.value.length < max_length) {
            counter += node.value.length;
            return node;
        }

        const nb_addable = max_length - counter;
        counter = max_length;

        return Object.assign({}, node, {
            value: node.value.substr(0, nb_addable) + "…",
        });
    });

    remove(truncated_tree, (node) => {
        return typeof node.type === "undefined";
    });

    if (images_counter > 0 && toString(truncated_tree).trim().length === 0) {
        return "<p><i>" + placeholder_image_text + "</i></p>";
    }

    return toHtml(truncated_tree);
}
github egoist / magi-deprecated / src / lib / index.js View on Github external
inBetween.length && inBetween.forEach(n => {
        if (!blockquoteNode && n.type === 'blockquote') {
          blockquoteNode = n
        } else {
          metaNodes.push(n)
        }
      })

      if (blockquoteNode) {
        meta.description = childrenToHtml(blockquoteNode.children)
      }

      meta.meta = childrenToHtml(metaNodes)

      remove(ast, heading1.node)
      remove(ast, inBetween)
      return ast
    }
github doczjs / docz / core / remark-docz / src / index.ts View on Github external
const valuesFromNodes = (tree: any) => (first: number, last: number) => {
  const values = []

  if (first !== last) {
    for (let i = last; i >= first; i--) {
      const found = tree.children[i]

      if (found.children && found.children.length > 0) {
        values.push(...found.children.map((child: any) => child.value))
      }

      if (found.value && found.value.length > 0) {
        values.push(found.value)
      }

      if (i !== first) remove(tree, found)
    }
  }

  return values
}
github egoist / magi-deprecated / src / lib / index.js View on Github external
const metaNodes = []
      inBetween.length && inBetween.forEach(n => {
        if (!blockquoteNode && n.type === 'blockquote') {
          blockquoteNode = n
        } else {
          metaNodes.push(n)
        }
      })

      if (blockquoteNode) {
        meta.description = childrenToHtml(blockquoteNode.children)
      }

      meta.meta = childrenToHtml(metaNodes)

      remove(ast, heading1.node)
      remove(ast, inBetween)
      return ast
    }

unist-util-remove

unist utility to remove nodes from a tree

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Popular unist-util-remove functions