From e0d1a16706058faf7f12815789d0c3148dfd8303 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 13 Sep 2024 11:59:36 +0200 Subject: [PATCH 1/5] Add `.tsbuildinfo` to `.gitignore` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ba85f45..570ca27 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules/ *.d.ts.map *.d.ts *.log +*.tsbuildinfo .DS_Store yarn.lock !/index.d.ts From 02394a1099f79cb6d777367dbc4b0df2aee9b49a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 13 Jan 2025 11:32:27 +0100 Subject: [PATCH 2/5] Update Actions --- .github/workflows/bb.yml | 12 ++++++------ .github/workflows/main.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/bb.yml b/.github/workflows/bb.yml index 0198fc3..3dbfce5 100644 --- a/.github/workflows/bb.yml +++ b/.github/workflows/bb.yml @@ -1,9 +1,3 @@ -name: bb -on: - issues: - types: [opened, reopened, edited, closed, labeled, unlabeled] - pull_request_target: - types: [opened, reopened, edited, closed, labeled, unlabeled] jobs: main: runs-on: ubuntu-latest @@ -11,3 +5,9 @@ jobs: - uses: unifiedjs/beep-boop-beta@main with: repo-token: ${{secrets.GITHUB_TOKEN}} +name: bb +on: + issues: + types: [closed, edited, labeled, opened, reopened, unlabeled] + pull_request_target: + types: [closed, edited, labeled, opened, reopened, unlabeled] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2ce794f..ade3921 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: node-version: ${{matrix.node}} - run: npm install - run: npm test - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 strategy: matrix: node: From 4b0db741958f4ccb54b5c65416444895ea5e2f87 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 13 Jan 2025 11:34:15 +0100 Subject: [PATCH 3/5] Update dev-dependencies --- lib/index.js | 4 ---- package.json | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index d854053..0dcb200 100644 --- a/lib/index.js +++ b/lib/index.js @@ -661,10 +661,6 @@ export function mdxJsxToMarkdown(options) { if (node.children && node.children.length > 0) { if (node.type === 'mdxJsxTextElement') { value += tracker.move( - // @ts-expect-error: `containerPhrasing` is typed correctly, but TS - // generates *hardcoded* types, which means that our dynamically added - // directives are not present. - // At some point, TS should fix that, and `from-markdown` should be fine. state.containerPhrasing(node, { ...tracker.current(), before: '>', diff --git a/package.json b/package.json index 7ff7ec2..79d2241 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "type-coverage": "^2.0.0", "typescript": "^5.0.0", "unist-util-remove-position": "^5.0.0", - "xo": "^0.59.0" + "xo": "^0.60.0" }, "scripts": { "prepack": "npm run build && npm run format", From a79fa126bf4688b727034f7c76f3e625c0329576 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 13 Jan 2025 11:40:46 +0100 Subject: [PATCH 4/5] Add positional info to expression attributes --- lib/index.js | 12 +++++++++++- test.js | 46 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 0dcb200..8f73b1e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -282,7 +282,15 @@ export function mdxJsxFromMarkdown() { const tag = this.data.mdxJsxTag assert(tag, 'expected `mdxJsxTag`') enterMdxJsxTagAnyAttribute.call(this, token) - tag.attributes.push({type: 'mdxJsxExpressionAttribute', value: ''}) + tag.attributes.push({ + type: 'mdxJsxExpressionAttribute', + value: '', + position: { + start: point(token.start), + // @ts-expect-error: `end` will be patched later. + end: undefined + } + }) this.buffer() } @@ -298,6 +306,8 @@ export function mdxJsxFromMarkdown() { const estree = token.estree tail.value = this.resume() + assert(tail.position !== undefined) + tail.position.end = point(token.end) if (estree) { tail.data = {estree} diff --git a/test.js b/test.js index 67ebb71..8b7d70f 100644 --- a/test.js +++ b/test.js @@ -279,7 +279,14 @@ test('mdxJsxFromMarkdown', async function (t) { type: 'mdxJsxTextElement', name: 'b', attributes: [ - {type: 'mdxJsxExpressionAttribute', value: '1 + 1'} + { + type: 'mdxJsxExpressionAttribute', + value: '1 + 1', + position: { + start: {line: 1, column: 6, offset: 5}, + end: {line: 1, column: 13, offset: 12} + } + } ], children: [] }, @@ -364,7 +371,14 @@ test('mdxJsxFromMarkdown', async function (t) { type: 'mdxJsxTextElement', name: 'b', attributes: [ - {type: 'mdxJsxExpressionAttribute', value: '...c'} + { + type: 'mdxJsxExpressionAttribute', + value: '...c', + position: { + start: {line: 1, column: 6, offset: 5}, + end: {line: 1, column: 12, offset: 11} + } + } ], children: [] }, @@ -395,7 +409,11 @@ test('mdxJsxFromMarkdown', async function (t) { attributes: [ { type: 'mdxJsxExpressionAttribute', - value: '...{b: 1, c: Infinity, d: false}' + value: '...{b: 1, c: Infinity, d: false}', + position: { + start: {line: 1, column: 4, offset: 3}, + end: {line: 1, column: 38, offset: 37} + } } ], children: [] @@ -428,6 +446,10 @@ test('mdxJsxFromMarkdown', async function (t) { { type: 'mdxJsxExpressionAttribute', value: '...b', + position: { + start: {line: 1, column: 4, offset: 3}, + end: {line: 1, column: 10, offset: 9} + }, data: { estree: { type: 'Program', @@ -1555,7 +1577,14 @@ test('mdxJsxFromMarkdown', async function (t) { type: 'mdxJsxTextElement', name: 'b', attributes: [ - {type: 'mdxJsxExpressionAttribute', value: 'c\nd'} + { + type: 'mdxJsxExpressionAttribute', + value: 'c\nd', + position: { + start: {line: 1, column: 8, offset: 7}, + end: {line: 2, column: 5, offset: 14} + } + } ], children: [] }, @@ -1593,7 +1622,14 @@ test('mdxJsxFromMarkdown', async function (t) { type: 'mdxJsxTextElement', name: 'b', attributes: [ - {type: 'mdxJsxExpressionAttribute', value: '...[1,\n2]'} + { + type: 'mdxJsxExpressionAttribute', + value: '...[1,\n2]', + position: { + start: {line: 1, column: 8, offset: 7}, + end: {line: 2, column: 6, offset: 20} + } + } ], children: [] }, From 0f3033ce1ce34e3c56bd81fc65e24a1dadb854c3 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 13 Jan 2025 11:46:23 +0100 Subject: [PATCH 5/5] 3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79d2241..6bf2a96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mdast-util-mdx-jsx", - "version": "3.1.3", + "version": "3.2.0", "description": "mdast extension to parse and serialize MDX or MDX.js JSX", "license": "MIT", "keywords": [