hast-util-phrasing
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    hast-util-phrasing

    Build Coverage Downloads Size Sponsors Backers Chat

    hast utility to check if a node is phrasing content.

    Install

    This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

    npm:

    npm install hast-util-phrasing

    Use

    import {phrasing} from 'hast-util-phrasing'
    
    // Given flow content:
    phrasing({
      type: 'element',
      tagName: 'div',
      children: [{type: 'text', value: 'Alpha'}]
    })
    // => false
    
    // Given a phrasing element:
    phrasing({
      type: 'element',
      tagName: 'meta',
      properties: {itemProp: 'bravo'},
      children: []
    })
    // => true
    
    // Given a non-phrasing element:
    phrasing({
      type: 'element',
      tagName: 'meta',
      properties: {charSet: 'utf8'},
      children: []
    })
    // => false
    
    // Given text:
    phrasing({type: 'text', value: 'Delta'})
    // => true

    API

    This package exports the following identifiers: phrasing. There is no default export.

    phrasing(node)

    Check if the given value is phrasing content.

    Parameters
    • node (*) — Value to check, typically Node.
    Returns

    boolean — Whether node passes the test.

    Security

    hast-util-phrasing does not change the syntax tree so there are no openings for cross-site scripting (XSS) attacks.

    Related

    Contribute

    See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

    This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

    License

    MIT © Titus Wormer

    Install

    npm i hast-util-phrasing

    DownloadsWeekly Downloads

    29,220

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    10.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • wooorm
    • kmck