micromark Subtokenization Utility

2.1.0 · active · verified Sun Apr 19

micromark-util-subtokenize is a low-level utility within the micromark ecosystem, designed to handle the internal process of tokenizing subtokens during markdown parsing. It provides the `subtokenize` function, which is crucial for extending micromark with custom parsing behaviors, particularly for nested content or specific markdown constructs. This package is currently at version 2.1.0 and is actively maintained as part of the unified collective's micromark project. Releases are typically coordinated with other micromark packages, following a frequent cadence in response to bug fixes, performance improvements, and new feature development within the core parser. Its primary differentiator is its specialized role in the micromark parsing pipeline, making it essential for advanced extension authors rather than direct end-user application.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how `subtokenize` is typically used within a micromark resolver function to process nested token events.

import {subtokenize} from 'micromark-util-subtokenize'
import type {Event, Resolver} from 'micromark-util-types'

/**
 * A resolver function type from micromark-util-types.
 * For custom micromark extensions, resolvers process a list of events.
 * In this example, `subtokenize` is called on the events to parse subcontent.
 *
 * @type {Resolver}
 */
function resolveContent(events: Array<Event>): Array<Event> {
  // `subtokenize` processes the event stream to tokenize any nested content.
  // This makes sure that, for instance, definitions are parsed before
  // their references in paragraphs.
  subtokenize(events)
  return events
}

view raw JSON →