syntax-tree / mdast-util-find-and-replace Goto Github PK
View Code? Open in Web Editor NEWmdast utility to find and replace text in a tree
Home Page: https://unifiedjs.com
License: MIT License
mdast utility to find and replace text in a tree
Home Page: https://unifiedjs.com
License: MIT License
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.
The test should pass.
The test fails because only the first match is replaced, resulting in only two nodes with the contents 'foo'
and 'asis'
, respectively.
macOS Ventura 13.5.2
No response
That the nodes generated via remark-breaks
do not contain position
information. This might be something that this underlying library could take care of.
I'm not 100% sure how much the remark-breaks
represents a typical usage of this library, but for the remark-break
case this library should be able to automatically infer the position of the break and subsequent text nodes.
Otherwise the replace()
callback could contain some context which allows the caller to infer the correct position information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.