@@ -4,7 +4,7 @@ import { PairMaker } from "./parser/PairMaker.js";
44import { SourceCode } from "./parser/SourceCode.js" ;
55import { IgnoreNodeManager } from "textlint-rule-helper" ;
66
7- const report = context => {
7+ const report = ( context ) => {
88 const { Syntax, report, RuleError } = context ;
99 const ignoreNodeManager = new IgnoreNodeManager ( ) ;
1010 return {
@@ -19,29 +19,37 @@ const report = context => {
1919 Syntax . BlockQuote ,
2020 Syntax . Comment
2121 ] ) ;
22- sentences . children . filter ( node => node . type === SentenceSplitterSyntax . Sentence ) . forEach ( sentence => {
23- const source = new SourceCode ( sentence . raw ) ;
24- const pairMaker = new PairMaker ( ) ;
25- const sentenceIndex = sentence . range [ 0 ] ;
26- while ( source . canRead ) {
27- // If the character is in ignored range, skip it
28- const characterIndex = sentenceIndex + source . index ;
29- // console.log(characterIndex, source.text[source.index], ignoreNodeManager.isIgnoredIndex(characterIndex));
30- if ( ! ignoreNodeManager . isIgnoredIndex ( characterIndex ) ) {
31- pairMaker . mark ( source ) ;
22+ sentences . children
23+ . filter ( ( node ) => node . type === SentenceSplitterSyntax . Sentence )
24+ . forEach ( ( sentence ) => {
25+ const source = new SourceCode ( sentence . raw ) ;
26+ const pairMaker = new PairMaker ( ) ;
27+ const sentenceIndex = sentence . range [ 0 ] ;
28+ while ( source . canRead ) {
29+ // If the character is in ignored range, skip it
30+ const characterIndex = sentenceIndex + source . index ;
31+ // console.log(characterIndex, source.text[source.index], ignoreNodeManager.isIgnoredIndex(characterIndex));
32+ if ( ! ignoreNodeManager . isIgnoredIndex ( characterIndex ) ) {
33+ pairMaker . mark ( source ) ;
34+ }
35+ source . peek ( ) ;
3236 }
33- source . peek ( ) ;
34- }
35- // Report Error for each existing context keys
36- source . contextLocations . forEach ( ( contextLocation ) => {
37- report ( node , new RuleError ( `Not found pair character for ${ contextLocation . pairMark . start } .
37+ // Report Error for each existing context keys
38+ source . contextLocations . forEach ( ( contextLocation ) => {
39+ report (
40+ node ,
41+ new RuleError (
42+ `Not found pair character for ${ contextLocation . pairMark . start } .
3843
3944You should close this sentence with ${ contextLocation . pairMark . end } .
40- This pair mark is called ${ contextLocation . pairMark . key } .` , {
41- index : ( sentenceIndex - node . range [ 0 ] ) + contextLocation . index
42- } ) ) ;
45+ This pair mark is called ${ contextLocation . pairMark . key } .` ,
46+ {
47+ index : sentenceIndex - node . range [ 0 ] + contextLocation . index
48+ }
49+ )
50+ ) ;
51+ } ) ;
4352 } ) ;
44- } ) ;
4553 }
4654 } ;
4755} ;
0 commit comments