Skip to content

Commit 8248ab9

Browse files
wooormtrueberryless
andcommitted
Fix 3 or more pairs
Closes GH-11. Closes GH-12. Co-authored-by: trueberryless <[email protected]>
1 parent f22e3b7 commit 8248ab9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default function retextQuotes(options) {
112112
expected = preferred === 'smart' ? '’' : "'"
113113
} else {
114114
const markers = preferred === 'smart' ? smart : straight
115-
expected = markers[(stack.length + 1) % markers.length]
115+
expected = markers[(stack.length - 1) % markers.length]
116116

117117
if (expected.length > 1) {
118118
expected = expected.charAt(style.type === 'open' ? 0 : 1)

test.js

+8
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ test('retextQuotes', async function (t) {
196196
}
197197
)
198198

199+
await t.test('should detect nesting correctly w/ 3 pairs', async function () {
200+
const file = await retext()
201+
.use(retextQuotes, {smart: ['“”', '‘’', '«»']})
202+
.process('A sentence “with ‘multiple «nested “quotes”»’”.')
203+
204+
assert.deepEqual(file.messages.map(String), [])
205+
})
206+
199207
await t.test('should deal with funky nesting', async function () {
200208
const file = await retext().use(retextQuotes).process(soManyOpenings)
201209

0 commit comments

Comments
 (0)