Skip to main content
Version: 1.x.x

@yozora/tokenizer-inline-math

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

inline math spec

A backtick string is a string of one or more backtick characters (`) that is neither preceded nor followed by a backtick.

A inline math begins with a backtick string + $ and ends with a $ + backtick string of equal length. The contents of the inline math are the characters between the two $ character, normalized in the following ways:

  • First, line endings are converted to spaces.

  • If the resulting string both begins and ends with a space character, but does not consist entirely of space characters, a single space character is removed from the front and back. This allows you to include code that begins or ends with backtick characters, which must be separated by whitespace from the opening or closing backtick strings.

Install

npm install --save @yozora/tokenizer-inline-math

Usage

tip

@yozora/tokenizer-inline-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, x < 0$`")

Options

NameTypeRequiredDefault
namestringfalse"@yozora/tokenizer-inline-math"
prioritynumberfalseTokenizerPriority.ATOMIC
  • 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.

    Exception: Delimiters of type full are always processed before other type delimiters.

Types

@yozora/tokenizer-inline-math produce InlineMath type nodes. See @yozora/ast for full base types.

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

export const InlineMathType = 'inlineMath'
export type InlineMathType = typeof InlineMathType

/**
* Inline math content.
*/
export type InlineMath = YastLiteral<InlineMathType>

Live Examples

  • Basic.