Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

mdast-util-math-inline

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-math-inline

mdast utility to parse and serialize inline math (:math[...])

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

mdast-util-math-inline

mdast utilities for inline math (:math[...]).

Install

npm install mdast-util-math-inline

Usage

import { fromMarkdown } from 'mdast-util-from-markdown'
import { toMarkdown } from 'mdast-util-to-markdown'
import { mathInline } from 'micromark-extension-math-inline'
import { mathInlineFromMarkdown, mathInlineToMarkdown } from 'mdast-util-math-inline'

// Parse
const tree = fromMarkdown(':math[x^2]', {
  extensions: [mathInline()],
  mdastExtensions: [mathInlineFromMarkdown()]
})

// Stringify
const md = toMarkdown(tree, {
  extensions: [mathInlineToMarkdown()]
})

AST

InlineMath

interface InlineMath extends Literal {
  type: 'inlineMath'
  value: string
  data?: {
    hName: 'code'
    hProperties: { className: ['language-math', 'math-inline'] }
    hChildren: [{ type: 'text', value: string }]
  }
}

The data fields enable compatibility with remark-rehype and rehype-katex.

Escaping

When serializing to markdown:

  • ] is escaped as \]
  • \ before ] or \ is escaped as \\
  • Balanced brackets don't need escaping

License

MIT

Keywords

mdast

FAQs

Package last updated on 27 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts