Skip to main content
Version: 1.x.x

@yozora/tokenizer-math

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

note

Install

npm install --save @yozora/tokenizer-math

Usage

tip

@yozora/tokenizer-math 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(`
$$x^2 + y^2=z^2$$

$$
f(x)=\left\lbrace\begin{aligned}
&x^2, &x < 0\\
&0, &x = 0\\
&x^3, &x > 0
\end{aligned}\right.
$$
`)

Options

NameTypeRequiredDefault
namestringfalse"@yozora/tokenizer-math"
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-math produce Math type nodes. See @yozora/ast for full base types.

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

export const MathType = 'math'
export type MathType = typeof MathType

/**
* Math content.
*/
export type Math = YastLiteral<MathType>

Live Examples

  • Single line math block.

      
      
  • Multiple line math block.