Releases: textlint/textlint-rule-helper
v2.3.1
v2.3.0
v2.2.4
v2.2.3
v2.2.2
v2.2.1
v2.2.0
Features
isPlainStrNode()
return true if the node is Str node and fill following conditions:
- the node is Str node
- the node is under the Paragraph node
- the node is not under the BlockQuote
This function is useful for the common use case.
If you want to lint Str node, but you do not want to lint styled node, this function is useful.
The styled node is Link, Strong, BlockQuote, Header, and it may be written by other people.
For example, you have added a link to your document, the link's title is written by other people.
Opposite of it, The plain Str node is just under the Paragraph node, and it was written by you.
Examples
Return true
str str str
- list text
Return false
# Header
![alt text](https://example.com)
[link title](https://example.com)
> BlockQuote text
**Strong text**
[linkReference][]
[^footnote text]
For more details, see https://github.com/textlint/textlint-rule-helper#rulehelperisplainstrnodenode-boolean
2.1.1
2.1.0
Bug Fixes
Features
- wrap: add
wrapReportHandler(context, options, handler): TextlintRuleReportHandler
function (c8fb78b)
wrapReportHandler
is high-level and declarative API for ignore nodes.
We have designed that wrapReportHandler
is easy to use.
If you want to ignore some Node's type, we recommended to use wrapReportHandler
.
import { wrapReportHandler } from "textlint-rule-helper";
const reporter = function (context) {
const { Syntax, getSource } = context;
return wrapReportHandler(context, {
ignoreNodeTypes: [Syntax.BlockQuote, Syntax.Code]
},report => { // <= wrap version of context.report
// handler should return a rule handler object
return {
[Syntax.Paragraph](node) {
const text = getSource(node);
const index = text.search("code");
/*
* Following text is matched, but it will not reported.
* ----
* This is `code`.
* > code
* ----
*/
if(index === -1){
return;
}
report(node, new context.RuleError(item.name, {
index
}));
}
}
});
};
module.exports = reporter;