Skip to content

Commit 7e5149c

Browse files
committed
feat: should not be closing quote if char before is separator
1 parent 1136362 commit 7e5149c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/smartQuotes.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ const isDoubleQuote = (char) => /^[«»"“”„]$/.test(char)
99
const isSingleQuote = (char) => /^[']$/.test(char)
1010
const isApostrophe = (char) => /^[']$/.test(char)
1111
const isWhitespace = (char) => /^\s$/.test(char)
12+
const isSeparatorOrWhitespace = (char) => /\s|[>\-]/.test(char)
1213

13-
const shouldBeOpeningQuote = (text, indexCharBefore) => indexCharBefore < 0 || /\s|[>\-]/.test(text[indexCharBefore])
14-
const shouldBeClosingQuote = (text, indexCharBefore) => !!text[indexCharBefore] && !isWhitespace(text[indexCharBefore])
14+
const shouldBeOpeningQuote = (text, indexCharBefore) => indexCharBefore < 0 || isSeparatorOrWhitespace(text[indexCharBefore])
15+
const shouldBeClosingQuote = (text, indexCharBefore) => !!text[indexCharBefore] && !isSeparatorOrWhitespace(text[indexCharBefore])
1516
const hasCharAfter = (textArr, indexCharAfter) => !!textArr[indexCharAfter] && !isWhitespace(textArr[indexCharAfter])
1617

1718
const replaceQuote = (range, index, quoteType) => {

0 commit comments

Comments
 (0)