Releases: textlint/textlint-util-to-string
Releases · textlint/textlint-util-to-string
v3.3.4
v3.3.3
v3.3.2
v3.3.0
What's Changed
Features
options.replacer
is a function that takes a node
and commands like maskValue
or emptyValue
.
If you want to modify the value
of the node, return command function calls.
// "This is a `code`."
const source = new StringSource(paragraphNode, {
replacer({ node, maskValue }) {
if (node.type === "Code") {
return maskValue("_"); // code => ____
}
}
});
console.log(source.toString()); // => "This is a ____."
maskValue(character: string)
: mask thevalue
of the node with the givencharacter
.emptyValue()
: replace thevalue
of the node with an empty string.
const AST = parse("This is `TEST`.");
const source = new StringSource(AST, {
replacer({ node, emptyValue }) {
if (node.type === "Code") {
return emptyValue();
}
}
});
assert.strictEqual(source.toString(), "This is .");
Examples:
Full Changelog: v3.2.0...v3.3.0
v3.2.0
v3.1.1
v3.1.0
3.0.0
Features
- src: Support
Html
node #11
Code Refactoring
- src: Convert to TypeScript (d12f33f)
BREAKING CHANGES
- src: export { StringSource } instead of export default
You need to change import statement.
- import StringSource from "textlint-util-to-string"
+ import { StringSource } from "textlint-util-to-string"