Back to Explore

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

GitHub
1 watchersOpen source

Last release: 1/3/2025

`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 actively maintained at least through early 2025, with the most recent documented updates on 2025-01-03 (3.0.2), though the overall update frequency is fairly low.
  • Apparent update cadence based on published updates, 3.0.0 on 2023-07-08, 3.0.1 on 2023-09-21 (about 2-3 months later), then 3.0.2 on 2025-01-03 (about 15+ months later).

AI summary generated Today

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

Recent updates

  • 3.0.2

    1/3/2025

    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

    9/21/2023

    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

    7/8/2023

    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

    1/26/2023

    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

    7/13/2022

    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

    5/19/2022

    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

    7/26/2021

    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

    6/21/2021

    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

    5/10/2021

    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

    2/9/2021

    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.