Have ideas to improve npm?Join in the discussion! »

    mdast-util-definitions
    TypeScript icon, indicating that this package has built-in type declarations

    5.0.0 • Public • Published

    mdast-util-definitions

    Build Coverage Downloads Size Sponsors Backers Chat

    mdast utility to get definitions by identifier.

    Supports funky keys, like __proto__ or toString.

    Install

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

    npm:

    npm install mdast-util-definitions

    Use

    import remark from 'remark'
    import {definitions} from 'mdast-util-definitions'
    
    var tree = remark().parse('[example]: https://example.com "Example"')
    
    var definition = definitions(tree)
    
    definition('example')
    // => {type: 'definition', 'title': 'Example', …}
    
    definition('foo')
    // => null

    API

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

    definitions(tree)

    Create a cache of all definitions in tree.

    Uses CommonMark precedence: prefers the first definitions for duplicate definitions.

    Returns

    Function

    definition(identifier)

    Parameters
    Returns

    Node?Definition, if found.

    Security

    Use of mdast-util-definitions does not involve hast or user content so there are no openings for cross-site scripting (XSS) attacks.

    Additionally, safe guards are in place to protect against prototype poisoning.

    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 mdast-util-definitions

    DownloadsWeekly Downloads

    2,951,423

    Version

    5.0.0

    License

    MIT

    Unpacked Size

    8.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar
    • avatar