diff --git a/dev/lib/index.js b/dev/lib/index.js index 2209f8b..6ec0383 100644 --- a/dev/lib/index.js +++ b/dev/lib/index.js @@ -247,6 +247,7 @@ function compiler(options) { characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, characterReferenceMarkerNumeric: onexitcharacterreferencemarker, characterReferenceValue: onexitcharacterreferencevalue, + characterReference: onexitcharacterreference, codeFenced: closer(onexitcodefenced), codeFencedFence: onexitcodefencedfence, codeFencedFenceInfo: onexitcodefencedfenceinfo, @@ -1201,11 +1202,20 @@ function compiler(options) { value = result } - const tail = this.stack.pop() + const tail = this.stack[this.stack.length - 1] assert(tail, 'expected `node`') - assert(tail.position, 'expected `node.position`') assert('value' in tail, 'expected `node.value`') tail.value += value + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcharacterreference(token) { + const tail = this.stack.pop() + assert(tail, 'expected `node`') + assert(tail.position, 'expected `node.position`') tail.position.end = point(token.end) } diff --git a/test/fixtures/link-reference-with-phrasing.json b/test/fixtures/link-reference-with-phrasing.json index bc3a1c6..f87d488 100644 --- a/test/fixtures/link-reference-with-phrasing.json +++ b/test/fixtures/link-reference-with-phrasing.json @@ -36,8 +36,8 @@ "offset": 7 } }, - "identifier": "`f`", "label": "`f`", + "identifier": "`f`", "referenceType": "collapsed" }, { @@ -70,8 +70,8 @@ }, "end": { "line": 2, - "column": 7, - "offset": 14 + "column": 8, + "offset": 15 } } } @@ -88,8 +88,8 @@ "offset": 18 } }, - "identifier": ";", "label": ";", + "identifier": ";", "referenceType": "collapsed" }, { @@ -140,8 +140,8 @@ "offset": 25 } }, - "identifier": "\\;", "label": ";", + "identifier": "\\;", "referenceType": "collapsed" }, { @@ -192,8 +192,8 @@ "offset": 31 } }, - "identifier": ";", "label": ";", + "identifier": ";", "referenceType": "collapsed" }, { @@ -242,8 +242,8 @@ }, "end": { "line": 5, - "column": 10, - "offset": 41 + "column": 11, + "offset": 42 } } } @@ -260,8 +260,8 @@ "offset": 45 } }, - "identifier": "`f`;", "label": "`f`;", + "identifier": "`f`;", "referenceType": "collapsed" }, { @@ -328,8 +328,8 @@ "offset": 55 } }, - "identifier": "`f`\\;", "label": "`f`;", + "identifier": "`f`\\;", "referenceType": "collapsed" }, { @@ -396,8 +396,8 @@ "offset": 64 } }, - "identifier": "`f`;", "label": "`f`;", + "identifier": "`f`;", "referenceType": "collapsed" } ], diff --git a/test/index.js b/test/index.js index ad6d766..83c6d45 100644 --- a/test/index.js +++ b/test/index.js @@ -4,6 +4,7 @@ import assert from 'node:assert/strict' import fs from 'node:fs/promises' +import process from 'node:process' import test from 'node:test' import {commonmark} from 'commonmark.json' import {fromHtml} from 'hast-util-from-html' @@ -1029,6 +1030,10 @@ test('fixtures', async function (t) { let expected try { + if ('UPDATE' in process.env) { + throw new Error('Update') + } + expected = JSON.parse(String(await fs.readFile(fp))) } catch { // New fixture.