Skip to content

Commit 80b5528

Browse files
committed
fix(sentence): use offset instead of index
index is private value
1 parent fd2a188 commit 80b5528

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/parser/AbbrMarker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,23 @@ export class AbbrMarker implements AbstractMarker {
8080
// Allow: Multi-period abbr
8181
// Example: U.S.A
8282
if (/^([a-zA-Z]\.){3,}$/.test(currentWord)) {
83-
return sourceCode.markContextRange([sourceCode.index, sourceCode.index + currentWord.length]);
83+
return sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
8484
}
8585
// EXCALAMATION_WORDS
8686
// Example: Yahoo!
8787
const isMatchedEXCALAMATION_WORDS = this.lang.EXCALAMATION_WORDS.some(abbr => {
8888
return compareNoCaseSensitive(abbr, currentWord);
8989
});
9090
if (isMatchedEXCALAMATION_WORDS) {
91-
return sourceCode.markContextRange([sourceCode.index, sourceCode.index + currentWord.length]);
91+
return sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
9292
}
9393
// PREPOSITIVE_ABBREVIATIONS
9494
// Example: Mr. Fuji
9595
const isMatchedPREPOSITIVE_ABBREVIATIONS = this.lang.PREPOSITIVE_ABBREVIATIONS.some(abbr => {
9696
return compareNoCaseSensitive(abbr, currentWord);
9797
});
9898
if (isMatchedPREPOSITIVE_ABBREVIATIONS) {
99-
return sourceCode.markContextRange([sourceCode.index, sourceCode.index + currentWord.length]);
99+
return sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
100100
}
101101
// ABBREVIATIONS
102102
const isMatched = this.lang.ABBREVIATIONS.some(abbr => {
@@ -111,11 +111,11 @@ export class AbbrMarker implements AbstractMarker {
111111
// Example: `I` as a sentence boundary and `I` as an abbreviation
112112
// > We make a good team, you and I. Did you see Albert I. Jones yesterday?
113113
if (isCapitalized(prevWord) && /[A-Z]\./.test(currentWord) && isCapitalized(nextWord)) {
114-
sourceCode.markContextRange([sourceCode.index, sourceCode.index + currentWord.length]);
114+
sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
115115
} else if (isMatched && !isCapitalized(nextWord)) {
116116
// Exception. This allow to write Capitalized word at next word
117117
// A.M. is store.
118-
sourceCode.markContextRange([sourceCode.index, sourceCode.index + currentWord.length]);
118+
sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
119119
}
120120
}
121121
}

src/parser/SourceCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export class SourceCode {
4848
}
4949

5050
isInContextRange() {
51-
const index = this.index;
51+
const offset = this.offset;
5252
return this.contextRanges.some(range => {
53-
return range[0] <= index && index < range[1];
53+
return range[0] <= offset && offset < range[1];
5454
});
5555
}
5656

0 commit comments

Comments
 (0)