Skip to content

Commit

Permalink
fix: fix sentence splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Apr 25, 2021
1 parent cca2a15 commit 7c17f05
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/textlint-rule-max-comma.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ export default function (context, options = defaultOptions) {
const { Syntax, RuleError, report, getSource } = context;
return {
[Syntax.Paragraph](node) {
const nodeWithoutCode = filter(node, (node) => {
const paragraphSentence = splitAST(node)
const paragraphSencenceWithoutNode = filter(paragraphSentence, (node) => {
return node.type !== Syntax.Code;
});
if (!nodeWithoutCode) {
return;
}
const sentences = splitAST(nodeWithoutCode).children.filter(node => node.type === SentenceSyntax.Sentence);
sentences.forEach(sentence => {
// This `sum(0,1,2,3,4,5,6,7,8,9,10)` is ok
// → This is ok
const sentencesWithoutCode = paragraphSencenceWithoutNode
.children
.filter(node => node.type === SentenceSyntax.Sentence);
sentencesWithoutCode.forEach(sentence => {
const source = new StringSource(sentence);
const sentenceValue = source.toString();
const count = countOfComma(sentenceValue);
Expand Down

0 comments on commit 7c17f05

Please sign in to comment.