How to use mdast-util-phrasing - 1 common examples

To help you get started, we’ve selected a few mdast-util-phrasing 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 blocks / blocks / packages / serializer / src / remark-slate.js View on Github external
if (node.type === 'jsx' && node.children) {
    // Remove open and closing jsx blocks
    const children = node.children.slice(1, node.children.length - 1)

    return {
      object: 'block',
      type: 'jsx',
      nodes: flatten(children.map(toSlate)),
      data: {
        type: getComponentName(node.children[0].value),
        props: {}
      }
    }
  }

  if (phrasing(node)) {
    const parentMark = {
      object: 'mark',
      type: node.type
    }

    const nodes = node.children.map(child => {
      const childMark = child.type !== 'text' && {
        object: 'mark',
        type: child.type
      }

      return {
        object: 'text',
        text: child.value,
        marks: [parentMark, childMark].filter(Boolean)
      }

mdast-util-phrasing

mdast utility to check if a node is phrasing content

MIT
Latest version published 3 months ago

Package Health Score

78 / 100
Full package analysis

Popular mdast-util-phrasing functions