Back to Explore

syntax-tree/mdast-util-find-and-replace

GitHub
2 watchersOpen source

Last release:

`mdast-util-find-and-replace` is a utility for searching and replacing text patterns inside an mdast (Markdown AST) tree, operating on complete values in `Text` nodes using strings or regular expressions. It’s useful for tasks like turning “mentions” detected by regex into other nodes, such as links, and can replace matches with text or custom nodes.

Project status

  • The source appears to be in quiet or maintenance mode, with the last upstream push on 2025-01-03, which is about 17 months before today (2026-06-09).
  • Apparent update cadence: after a sequence of active changes (2021 to 2023), updates became infrequent, with 3.0.2 arriving in 2025, and the previous update before that being 3.0.1 (2023), then 3.0.0 (2023).

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • 3.0.2

    Release 3.0.2 is primarily a TypeScript/JSDoc typing refactor, switching type documentation to use JSDoc `@import` syntax and enabling declaration maps for generated `.d.ts` output. The runtime code changes appear to be limited to type annotations, with most other diffs coming from tooling, CI, and metadata updates.

  • 3.0.1

    Release 3.0.1 ships a targeted fix for `findAndReplace` where returning `false` from the replacer could leave a global RegExp `lastIndex` in the wrong position. The release notes describe resetting `lastIndex` when the replacer returns `false`.

  • 3.0.0

    mdast-util-find-and-replace 3.0.0 is a breaking major release that changes the API shape for how find-and-replace rules are provided (tuples or list of tuples only), and it no longer returns the modified tree. It also raises the minimum Node.js version to 16 and modernizes package/export metadata. The diff shows several additional type and packaging changes that are not explicitly called out in the release notes.

    Breaking
  • 2.2.2

    Release 2.2.2 is presented as a documentation and code-style update, plus a tsconfig change, with no explicit feature or breaking change called out. The actual diff shows the bulk of work is JSDoc and README type documentation, along with tooling changes (CI, build script, test runner, and dependency/devDependency adjustments).

  • 2.2.1

    Release 2.2.1 fixes a bug in `findAndReplace` when a replace callback successfully replaces an earlier match and then returns `false` for a later match. Tooling/CI related changes also appear in the repo (Node LTS matrix update, devDependency bumps), but these are not mentioned in the release notes.

  • 2.2.0

    Release 2.2.0 adds a new `stack` field to the RegExp match object passed to replace callbacks, and includes bug fixes around replacement behavior and `false` handling. The diff also shows a larger internal refactor (code moved under `lib/`) plus dependency upgrades and documentation refreshes.

    Features
  • 2.1.0

    Release 2.1.0 updates the library to use mdast types more directly and enables TypeScript `strict` mode. The code diff also includes runtime behavior adjustments around how replacement results are normalized and when the replacement handler is invoked.

    Breaking
  • 2.0.1

    Release 2.0.1 primarily addresses typing for the `replace` callback in `findAndReplace` (fixing the types described for the function’s rest parameters). The code diff also includes some internal refactoring (var to let/const) and non-code changes to CI configuration and project lint/type-check settings.

    Security
  • 2.0.0

    Version 2.0.0 is a major rewrite centered on converting the package to ESM, adding JSDoc-based typing support (generated .d.ts), and fixing a bug related to missed finds during replacements. The release notes only mention these three high-level items, but the diff shows additional breaking or behavior-adjacent changes around export shape, input detection, error types, and multiple dependency major version bumps.

    BreakingFeatures
  • 1.1.1

    Release 1.1.1 is a small patch release that adjusts how `findAndReplace` detects whether the `find` argument represents a regex-like pattern. The documented change is meant to avoid incorrect handling due to upcoming `Array#lastIndex` behavior.