Skip to content

In a node containing multiple matches of the search string or regex, only the first occurrence is replaced #5

Closed as not planned
@lpsinger

Description

@lpsinger

Initial checklist

Affected packages and versions

mdast-util-find-and-replace@3.0.0

Link to runnable example

#4

Steps to reproduce

See new unit test in PR above. The search string is the regular expression /(emph|sis)/ and the replacement text is 'foo'. So the text node with the content 'emphasis' should be replaced with three new text nodes, with the contents 'foo', 'a', and 'foo', respectively.

Expected behavior

The test should pass.

Actual behavior

The test fails because only the first match is replaced, resulting in only two nodes with the contents 'foo' and 'asis', respectively.

Affected runtime and version

node@18.17.1

Affected package manager and version

npm@10.1.0

Affected OS and version

macOS Ventura 13.5.2

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🤷 no/invalidThis cannot be acted upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions