@yozora/parser-gfm
TypeScript icon, indicating that this package has built-in type declarations

2.3.1 • Public • Published

@yozora/parser-gfm


A markdown parser with built-in tokenizers to fully support GFM (without GFM extensions).

See @yozora/parser-gfm documentation for details.

Install

  • npm

    npm install --save @yozora/parser-gfm
  • yarn

    yarn add @yozora/parser-gfm

Usage

  • Basic

    import GfmParser from '@yozora/parser-gfm'
    
    const parser = new GfmParser()
    
    // parse markdown source content.
    parser.parse('source markdown content')
    
    // parse markdown source content with custom options.
    parser.parse(
      'source markdown content',  // markdown source contents, `string|Iterable<string>`
      {},                         // ParseOptions, optional.
    )
    
    // parse multiple markdown source content pieces.
    parser.parse(['source', 'contents'])
  • Use withing generator:

    import GfmParser from '@yozora/parser-gfm'
    
    const parser = new GfmParser()
    
    /**
     * String stream is supported through the iterator API.
     */
    function* source () {
      yield 'hello',
      yield 'world',
    }
    
    parser.parse(source())

Options

  • Constructor Options

    Name Type Required Description
    blockFallbackTokenizer BlockFallbackTokenizer false Fallback tokenizer on processing block structure phase
    inlineFallbackTokenizer InlineFallbackTokenizer false Fallback tokenizer on processing inline structure phase
    defaultParseOptions ParseOptions false Default options for parse()
  • ParseOptions

    Name Type Required Description
    shouldReservePosition boolean false Whether it is necessary to reserve the position in the Node produced
    presetDefinitions Array<Omit<Definition, 'type'> false Preset definitions
    presetFootnoteDefinitions Array<Omit<FootnoteDefinition, 'type'> false Preset footnote definition

Overview

Related

Package Sidebar

Install

npm i @yozora/parser-gfm

Weekly Downloads

10

Version

2.3.1

License

MIT

Unpacked Size

83.5 kB

Total Files

8

Last publish

Collaborators

  • lemonclown