Read the inline text, and decode the escapes and references CommonMark spells #33
@@ -231,7 +231,6 @@ function claimsCharacter(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// The last `]` link text could close on, so a `[` ahead of it opens one and a `[` past it cannot.
|
|
||||||
// A `]` the emitter spelled sits inside a construct that binds before link text does.
|
// A `]` the emitter spelled sits inside a construct that binds before link text does.
|
||||||
function lastLinkClose(scan: string, escapings: readonly (InlineEscaping | undefined)[]): number {
|
function lastLinkClose(scan: string, escapings: readonly (InlineEscaping | undefined)[]): number {
|
||||||
for (let cursor = scan.length - 1; cursor >= 0; cursor -= 1) {
|
for (let cursor = scan.length - 1; cursor >= 0; cursor -= 1) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import test from 'node:test'
|
|
||||||
import { dirname, join } from 'node:path'
|
|
||||||
import { fileURLToPath } from 'node:url'
|
|
||||||
import { readFileSync } from 'node:fs'
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { dirname, join } from 'node:path'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
import { readEntityReference } from './entity-references.ts'
|
import { readEntityReference } from './entity-references.ts'
|
||||||
|
|
||||||
@@ -16,6 +16,6 @@ test('every packed reference parts into one name and one value the table decodes
|
|||||||
assert.equal(references.length, 2125)
|
assert.equal(references.length, 2125)
|
||||||
for (const reference of references) {
|
for (const reference of references) {
|
||||||
assert.match(reference, /^[A-Za-z][A-Za-z0-9]*~[^ ~]+$/)
|
assert.match(reference, /^[A-Za-z][A-Za-z0-9]*~[^ ~]+$/)
|
||||||
assert.ok(readEntityReference(`&${reference.slice(0, reference.indexOf('~'))};`, 0) !== undefined)
|
assert.ok((readEntityReference(`&${reference.slice(0, reference.indexOf('~'))};`, 0)?.text ?? '') !== '')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user