Skip to main content
Version: 3.x.x 🚧

@yozora/tokenizer-admonition

Npm VersionNpm DownloadNpm LicenseModule formats: cjs, esmNode.js VersionTested with JestCode Style: prettier

note

Install

npm install --save @yozora/tokenizer-admonition

Usage

tip

@yozora/tokenizer-admonition has been integrated into @yozora/parser, so you can use YozoraParser directly.

import YozoraParser from '@yozora/parser'

const parser = new YozoraParser()

// parse source markdown content
parser.parse(`
:::info[this is a info type admonition]
waw

### some block contents
:::
`)

Options

NameTypeRequiredDefault
namestringfalse"@yozora/tokenizer-admonition"
prioritynumberfalseTokenizerPriority.FENCED_BLOCK
  • name: The unique name of the tokenizer, used to bind the token it generates, to determine the tokenizer that should be called in each life cycle of the token in the entire matching / parsing phase.

  • priority: Priority of the tokenizer, determine the order of processing, high priority priority execution. interruptable. In addition, in the match-block stage, a high-priority tokenizer can interrupt the matching process of a low-priority tokenizer.

Types

@yozora/tokenizer-admonition produce Admonition type nodes. See @yozora/ast for full base types.

import type { Parent } from '@yozora/ast'

export const AdmonitionType = 'admonition'
export type AdmonitionType = typeof AdmonitionType

/**
* Admonitions are block elements. The titles can include inline markdown and
* the body can include any block markdown except another admonition.
* @see https://github.com/elviswolcott/remark-admonitions
*/
export interface Admonition extends Parent<AdmonitionType> {
/**
* Keyword of an admonition.
*/
keyword: 'note' | 'important' | 'tip' | 'caution' | 'warning' | string
/**
* Admonition title.
*/
title: Node[]
}

Live Examples

  • Basic Usage.

    #1
      
      
  • Admonition body could be empty.

    #2
      
      
  • Admonition body supported full features of markdown.

    #3
      
      
  • Admonition title could include inlines.

    #4