From b11d3b9546c406821cf423e26cc0005f1b0db50e Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 16 Jun 2026 15:11:29 +0800 Subject: [PATCH 1/5] chore(deps): upgrade all dependencies to latest major versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - typescript 4→5, jest 27→29, ts-jest 27→29 - @types/jest 26→29, @types/node 16→20 - remark 14→15, remark-directive 2→4 - remark-frontmatter 4→5, remark-math 5→6 - Replace remark-gfm with individual GFM plugins to remove autolink literal false positives with CJK - Remove mdast-util-gfm-autolink-literal monkey-patch - Fix @tootallnate/once vulnerability via jest upgrade --- __tests__/__snapshots__/index.spec.ts.snap | 329 ++++++--------------- package.json | 36 ++- src/parse-md.ts | 39 ++- 3 files changed, 153 insertions(+), 251 deletions(-) diff --git a/__tests__/__snapshots__/index.spec.ts.snap b/__tests__/__snapshots__/index.spec.ts.snap index 75a816e..ac05374 100644 --- a/__tests__/__snapshots__/index.spec.ts.snap +++ b/__tests__/__snapshots__/index.spec.ts.snap @@ -1,16 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`test lint-md-parser invoke parseMd 1`] = ` -Object { - "children": Array [ - Object { - "position": Object { - "end": Object { +{ + "children": [ + { + "position": { + "end": { "column": 4, "line": 8, "offset": 68, }, - "start": Object { + "start": { "column": 1, "line": 1, "offset": 0, @@ -24,16 +24,16 @@ tags: - IDEA - Spring Boot", }, - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "position": { + "end": { "column": 14, "line": 10, "offset": 83, }, - "start": Object { + "start": { "column": 3, "line": 10, "offset": 72, @@ -44,13 +44,13 @@ tags: }, ], "depth": 1, - "position": Object { - "end": Object { + "position": { + "end": { "column": 14, "line": 10, "offset": 83, }, - "start": Object { + "start": { "column": 1, "line": 10, "offset": 70, @@ -58,16 +58,16 @@ tags: }, "type": "heading", }, - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "position": { + "end": { "column": 6, "line": 12, "offset": 90, }, - "start": Object { + "start": { "column": 1, "line": 12, "offset": 85, @@ -77,13 +77,13 @@ tags: "value": "你好 世界", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 6, "line": 12, "offset": 90, }, - "start": Object { + "start": { "column": 1, "line": 12, "offset": 85, @@ -91,169 +91,32 @@ tags: }, "type": "paragraph", }, - Object { - "children": Array [ - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { - "column": 16, - "line": 14, - "offset": 107, - }, - "start": Object { - "column": 1, - "line": 14, - "offset": 92, - }, - }, - "type": "text", - "value": "www.example.com", - }, - ], - "position": Object { - "end": Object { - "column": 16, - "line": 14, - "offset": 107, - }, - "start": Object { - "column": 1, - "line": 14, - "offset": 92, - }, - }, - "title": null, - "type": "link", - "url": "http://www.example.com", - }, - Object { - "position": Object { - "end": Object { - "column": 18, - "line": 14, - "offset": 109, - }, - "start": Object { - "column": 16, - "line": 14, - "offset": 107, - }, - }, - "type": "text", - "value": ", ", - }, - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { - "column": 37, - "line": 14, - "offset": 128, - }, - "start": Object { - "column": 18, - "line": 14, - "offset": 109, - }, - }, - "type": "text", - "value": "https://example.com", - }, - ], - "position": Object { - "end": Object { - "column": 37, - "line": 14, - "offset": 128, - }, - "start": Object { - "column": 18, - "line": 14, - "offset": 109, - }, - }, - "title": null, - "type": "link", - "url": "https://example.com", - }, - Object { - "position": Object { - "end": Object { - "column": 43, - "line": 14, - "offset": 134, - }, - "start": Object { - "column": 37, - "line": 14, - "offset": 128, - }, - }, - "type": "text", - "value": ", and ", - }, - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { - "column": 62, - "line": 14, - "offset": 153, - }, - "start": Object { - "column": 43, - "line": 14, - "offset": 134, - }, - }, - "type": "text", - "value": "contact@example.com", - }, - ], - "position": Object { - "end": Object { - "column": 62, - "line": 14, - "offset": 153, - }, - "start": Object { - "column": 43, - "line": 14, - "offset": 134, - }, - }, - "title": null, - "type": "link", - "url": "mailto:contact@example.com", - }, - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "position": { + "end": { "column": 63, "line": 14, "offset": 154, }, - "start": Object { - "column": 62, + "start": { + "column": 1, "line": 14, - "offset": 153, + "offset": 92, }, }, "type": "text", - "value": ".", + "value": "www.example.com, https://example.com, and contact@example.com.", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 63, "line": 14, "offset": 154, }, - "start": Object { + "start": { "column": 1, "line": 14, "offset": 92, @@ -261,18 +124,18 @@ tags: }, "type": "paragraph", }, - Object { - "children": Array [ - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "children": [ + { + "position": { + "end": { "column": 16, "line": 16, "offset": 171, }, - "start": Object { + "start": { "column": 7, "line": 16, "offset": 162, @@ -282,13 +145,13 @@ tags: "value": "Big note.", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 16, "line": 16, "offset": 171, }, - "start": Object { + "start": { "column": 7, "line": 16, "offset": 162, @@ -299,13 +162,13 @@ tags: ], "identifier": "1", "label": "1", - "position": Object { - "end": Object { + "position": { + "end": { "column": 16, "line": 16, "offset": 171, }, - "start": Object { + "start": { "column": 1, "line": 16, "offset": 156, @@ -313,18 +176,18 @@ tags: }, "type": "footnoteDefinition", }, - Object { - "children": Array [ - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "children": [ + { + "position": { + "end": { "column": 5, "line": 18, "offset": 177, }, - "start": Object { + "start": { "column": 2, "line": 18, "offset": 174, @@ -334,13 +197,13 @@ tags: "value": "one", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 6, "line": 18, "offset": 178, }, - "start": Object { + "start": { "column": 1, "line": 18, "offset": 173, @@ -348,14 +211,14 @@ tags: }, "type": "delete", }, - Object { - "position": Object { - "end": Object { + { + "position": { + "end": { "column": 10, "line": 18, "offset": 182, }, - "start": Object { + "start": { "column": 6, "line": 18, "offset": 178, @@ -364,16 +227,16 @@ tags: "type": "text", "value": " or ", }, - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "position": { + "end": { "column": 15, "line": 18, "offset": 187, }, - "start": Object { + "start": { "column": 12, "line": 18, "offset": 184, @@ -383,13 +246,13 @@ tags: "value": "two", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 17, "line": 18, "offset": 189, }, - "start": Object { + "start": { "column": 10, "line": 18, "offset": 182, @@ -397,14 +260,14 @@ tags: }, "type": "delete", }, - Object { - "position": Object { - "end": Object { + { + "position": { + "end": { "column": 25, "line": 18, "offset": 197, }, - "start": Object { + "start": { "column": 17, "line": 18, "offset": 189, @@ -414,13 +277,13 @@ tags: "value": " tildes.", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 25, "line": 18, "offset": 197, }, - "start": Object { + "start": { "column": 1, "line": 18, "offset": 173, @@ -428,32 +291,32 @@ tags: }, "type": "paragraph", }, - Object { - "children": Array [ - Object { - "position": Object { - "end": Object { + { + "children": [ + { + "position": { + "end": { "column": 78, "line": 20, "offset": 276, }, - "start": Object { + "start": { "column": 1, "line": 20, "offset": 199, }, }, "type": "text", - "value": "假设你打开了浏览器,并且搜索了 \\"www.google.com\\"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。", + "value": "假设你打开了浏览器,并且搜索了 "www.google.com"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 78, "line": 20, "offset": 276, }, - "start": Object { + "start": { "column": 1, "line": 20, "offset": 199, @@ -462,13 +325,13 @@ tags: "type": "paragraph", }, ], - "position": Object { - "end": Object { + "position": { + "end": { "column": 1, "line": 21, "offset": 277, }, - "start": Object { + "start": { "column": 1, "line": 1, "offset": 0, @@ -492,10 +355,12 @@ tags: 你好 世界 -[www.example.com](http://www.example.com), , and . +www.example.com, https://example.com, and contact@example.com. [^1]: Big note. ~~one~~ or ~~two~~ tildes. + +假设你打开了浏览器,并且搜索了 "www.google.com"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。 " `; diff --git a/package.json b/package.json index 9884b3d..c08d1d0 100644 --- a/package.json +++ b/package.json @@ -21,33 +21,41 @@ "build:dist": "webpack --config webpack.config.ts", "build:ts-declaration": "tsc && api-extractor run --local --verbose", "lint": "eslint --ext js,jsx,ts,tsx ./src", - "test": "jest" + "test": "jest", + "test:update": "jest --updateSnapshot" }, "devDependencies": { "@attachments/eslint-config": "^0.3.3", "@microsoft/api-extractor": "^7.23.2", - "@types/jest": "^26.0.24", - "@types/node": "^16.4.6", + "@types/jest": "^29.0.0", + "@types/node": "^20.0.0", + "@types/unist": "^3.0.0", "concurrently": "^7.1.0", - "eslint": "^8.26.0", - "jest": "^27.0.6", + "eslint": "^8.57.0", + "jest": "^29.0.0", "npm-run-all": "^4.1.5", "rimraf": "^3.0.2", "terser-webpack-plugin": "^5.3.1", - "ts-jest": "^27.0.4", + "ts-jest": "^29.0.0", "ts-loader": "^9.3.0", "ts-node": "^10.1.0", - "typescript": "^4.3.5", + "typescript": "^5.0.0", "webpack": "^5.72.0", "webpack-cli": "^4.9.2" }, "dependencies": { - "@types/unist": "^2.0.6", - "mdast-util-gfm-autolink-literal": "^1.0.2", - "remark": "^14.0.2", - "remark-directive": "^2.0.1", - "remark-frontmatter": "^4.0.1", - "remark-gfm": "^3.0.1", - "remark-math": "^5.1.1" + "mdast-util-gfm-footnote": "^2.1.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "micromark-extension-gfm-footnote": "^2.1.0", + "micromark-extension-gfm-strikethrough": "^2.1.0", + "micromark-extension-gfm-table": "^2.1.1", + "micromark-extension-gfm-task-list-item": "^2.1.0", + "micromark-util-combine-extensions": "^2.0.1", + "remark": "^15.0.0", + "remark-directive": "^4.0.0", + "remark-frontmatter": "^5.0.0", + "remark-math": "^6.0.0" } } diff --git a/src/parse-md.ts b/src/parse-md.ts index e2dbbea..be3c567 100644 --- a/src/parse-md.ts +++ b/src/parse-md.ts @@ -1,20 +1,49 @@ import frontmatter from 'remark-frontmatter'; -import remarkGfm from 'remark-gfm'; import remarkDirective from 'remark-directive'; import remarkMath from 'remark-math'; import { remark } from 'remark'; -import { gfmAutolinkLiteralFromMarkdown } from 'mdast-util-gfm-autolink-literal'; +import { combineExtensions } from 'micromark-util-combine-extensions'; +import { gfmFootnote } from 'micromark-extension-gfm-footnote'; +import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough'; +import { gfmTable } from 'micromark-extension-gfm-table'; +import { gfmTaskListItem } from 'micromark-extension-gfm-task-list-item'; +import { gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown } from 'mdast-util-gfm-footnote'; +import { gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown } from 'mdast-util-gfm-strikethrough'; +import { gfmTableFromMarkdown, gfmTableToMarkdown } from 'mdast-util-gfm-table'; +import { gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown } from 'mdast-util-gfm-task-list-item'; import type { MarkdownNode } from './types'; -// https://github.com/remarkjs/remark-gfm/issues/16,解决某些 text 节点没有 position 的问题 -gfmAutolinkLiteralFromMarkdown.transforms = []; +const gfmExtension = combineExtensions([ + gfmFootnote(), + gfmStrikethrough(), + gfmTable(), + gfmTaskListItem(), +]); const depsLink = remark() .use(frontmatter) - .use(remarkGfm) .use(remarkDirective) .use(remarkMath); +// Manually register GFM extensions (without autolink literals to avoid false positives) +const data = depsLink.data(); +data.micromarkExtensions = data.micromarkExtensions || []; +data.micromarkExtensions.push(gfmExtension); +data.fromMarkdownExtensions = data.fromMarkdownExtensions || []; +data.fromMarkdownExtensions.push( + gfmFootnoteFromMarkdown(), + gfmStrikethroughFromMarkdown(), + gfmTableFromMarkdown(), + gfmTaskListItemFromMarkdown(), +); +data.toMarkdownExtensions = data.toMarkdownExtensions || []; +data.toMarkdownExtensions.push( + gfmFootnoteToMarkdown(), + gfmStrikethroughToMarkdown(), + gfmTableToMarkdown(), + gfmTaskListItemToMarkdown(), +); + /** * 将 Markdown 解析成 ast * From 069fdd4b1033fb479421225becb6670218f2a9ad Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 16 Jun 2026 15:22:30 +0800 Subject: [PATCH 2/5] chore(ci): align pnpm version to 11.0.9 - Add packageManager field to package.json - Update CI workflow pnpm version from ^10.9.8 to 11.0.9 --- .github/workflows/build.yml | 16 ++++++++-------- package.json | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb0b56b..434a1e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,15 +7,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6.0.2 - name: Setup Node.js environment - uses: actions/setup-node@v3.1.1 + uses: actions/setup-node@v6.3.0 - name: Setup PNPM - uses: pnpm/action-setup@v2.2.1 + uses: pnpm/action-setup@v6.0.8 with: - version: 6.32.3 + version: 11.0.9 - name: Install modules and build projects run: pnpm install && pnpm run build @@ -27,15 +27,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6.0.2 - name: Setup Node.js environment - uses: actions/setup-node@v3.1.1 + uses: actions/setup-node@v6.3.0 - name: Setup PNPM - uses: pnpm/action-setup@v2.2.1 + uses: pnpm/action-setup@v6.0.8 with: - version: 6.32.3 + version: 11.0.9 - name: Install modules and build projects run: pnpm install && pnpm run build diff --git a/package.json b/package.json index c08d1d0..a405b2a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ ], "homepage": "https://github.com/lint-md", "license": "MIT", + "packageManager": "pnpm@11.0.9", "main": "./dist/lint-md-parser.js", "typings": "./dist/lint-md-parser.d.ts", "files": [ From d712e78825f582240f0c00d1244bae8b46b32757 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 16 Jun 2026 15:24:05 +0800 Subject: [PATCH 3/5] chore: remove packageManager field --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index a405b2a..c08d1d0 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ ], "homepage": "https://github.com/lint-md", "license": "MIT", - "packageManager": "pnpm@11.0.9", "main": "./dist/lint-md-parser.js", "typings": "./dist/lint-md-parser.d.ts", "files": [ From 8e08f712a38689d9f1fcf0a135e0c6bec0ed3310 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 16 Jun 2026 15:42:55 +0800 Subject: [PATCH 4/5] revert(deps): rollback remark ecosystem to 14.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - remark 15→14, remark-directive 4→2, remark-frontmatter 4→5, remark-math 5→6 - Restore remark-gfm@3 and mdast-util-gfm-autolink-literal@1 - Restore original parse-md.ts with monkey-patch - Keep devDependencies upgrades (jest 29, typescript 5) --- __tests__/__snapshots__/index.spec.ts.snap | 147 ++++++++++++++++++++- package.json | 21 +-- src/parse-md.ts | 39 +----- 3 files changed, 154 insertions(+), 53 deletions(-) diff --git a/__tests__/__snapshots__/index.spec.ts.snap b/__tests__/__snapshots__/index.spec.ts.snap index ac05374..2852563 100644 --- a/__tests__/__snapshots__/index.spec.ts.snap +++ b/__tests__/__snapshots__/index.spec.ts.snap @@ -94,11 +94,29 @@ tags: { "children": [ { + "children": [ + { + "position": { + "end": { + "column": 16, + "line": 14, + "offset": 107, + }, + "start": { + "column": 1, + "line": 14, + "offset": 92, + }, + }, + "type": "text", + "value": "www.example.com", + }, + ], "position": { "end": { - "column": 63, + "column": 16, "line": 14, - "offset": 154, + "offset": 107, }, "start": { "column": 1, @@ -106,8 +124,127 @@ tags: "offset": 92, }, }, + "title": null, + "type": "link", + "url": "http://www.example.com", + }, + { + "position": { + "end": { + "column": 18, + "line": 14, + "offset": 109, + }, + "start": { + "column": 16, + "line": 14, + "offset": 107, + }, + }, + "type": "text", + "value": ", ", + }, + { + "children": [ + { + "position": { + "end": { + "column": 37, + "line": 14, + "offset": 128, + }, + "start": { + "column": 18, + "line": 14, + "offset": 109, + }, + }, + "type": "text", + "value": "https://example.com", + }, + ], + "position": { + "end": { + "column": 37, + "line": 14, + "offset": 128, + }, + "start": { + "column": 18, + "line": 14, + "offset": 109, + }, + }, + "title": null, + "type": "link", + "url": "https://example.com", + }, + { + "position": { + "end": { + "column": 43, + "line": 14, + "offset": 134, + }, + "start": { + "column": 37, + "line": 14, + "offset": 128, + }, + }, + "type": "text", + "value": ", and ", + }, + { + "children": [ + { + "position": { + "end": { + "column": 62, + "line": 14, + "offset": 153, + }, + "start": { + "column": 43, + "line": 14, + "offset": 134, + }, + }, + "type": "text", + "value": "contact@example.com", + }, + ], + "position": { + "end": { + "column": 62, + "line": 14, + "offset": 153, + }, + "start": { + "column": 43, + "line": 14, + "offset": 134, + }, + }, + "title": null, + "type": "link", + "url": "mailto:contact@example.com", + }, + { + "position": { + "end": { + "column": 63, + "line": 14, + "offset": 154, + }, + "start": { + "column": 62, + "line": 14, + "offset": 153, + }, + }, "type": "text", - "value": "www.example.com, https://example.com, and contact@example.com.", + "value": ".", }, ], "position": { @@ -355,12 +492,12 @@ tags: 你好 世界 -www.example.com, https://example.com, and contact@example.com. +[www.example.com](http://www.example.com), , and . [^1]: Big note. ~~one~~ or ~~two~~ tildes. -假设你打开了浏览器,并且搜索了 "www.google.com"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。 +假设你打开了浏览器,并且搜索了 "www\\.google.com"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。 " `; diff --git a/package.json b/package.json index c08d1d0..baca777 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@microsoft/api-extractor": "^7.23.2", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", - "@types/unist": "^3.0.0", "concurrently": "^7.1.0", "eslint": "^8.57.0", "jest": "^29.0.0", @@ -44,18 +43,12 @@ "webpack-cli": "^4.9.2" }, "dependencies": { - "mdast-util-gfm-footnote": "^2.1.0", - "mdast-util-gfm-strikethrough": "^2.0.0", - "mdast-util-gfm-table": "^2.0.0", - "mdast-util-gfm-task-list-item": "^2.0.0", - "micromark-extension-gfm-footnote": "^2.1.0", - "micromark-extension-gfm-strikethrough": "^2.1.0", - "micromark-extension-gfm-table": "^2.1.1", - "micromark-extension-gfm-task-list-item": "^2.1.0", - "micromark-util-combine-extensions": "^2.0.1", - "remark": "^15.0.0", - "remark-directive": "^4.0.0", - "remark-frontmatter": "^5.0.0", - "remark-math": "^6.0.0" + "@types/unist": "^2.0.6", + "mdast-util-gfm-autolink-literal": "^1.0.2", + "remark": "^14.0.2", + "remark-directive": "^2.0.1", + "remark-frontmatter": "^4.0.1", + "remark-gfm": "^3.0.1", + "remark-math": "^5.1.1" } } diff --git a/src/parse-md.ts b/src/parse-md.ts index be3c567..e2dbbea 100644 --- a/src/parse-md.ts +++ b/src/parse-md.ts @@ -1,49 +1,20 @@ import frontmatter from 'remark-frontmatter'; +import remarkGfm from 'remark-gfm'; import remarkDirective from 'remark-directive'; import remarkMath from 'remark-math'; import { remark } from 'remark'; -import { combineExtensions } from 'micromark-util-combine-extensions'; -import { gfmFootnote } from 'micromark-extension-gfm-footnote'; -import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough'; -import { gfmTable } from 'micromark-extension-gfm-table'; -import { gfmTaskListItem } from 'micromark-extension-gfm-task-list-item'; -import { gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown } from 'mdast-util-gfm-footnote'; -import { gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown } from 'mdast-util-gfm-strikethrough'; -import { gfmTableFromMarkdown, gfmTableToMarkdown } from 'mdast-util-gfm-table'; -import { gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown } from 'mdast-util-gfm-task-list-item'; +import { gfmAutolinkLiteralFromMarkdown } from 'mdast-util-gfm-autolink-literal'; import type { MarkdownNode } from './types'; -const gfmExtension = combineExtensions([ - gfmFootnote(), - gfmStrikethrough(), - gfmTable(), - gfmTaskListItem(), -]); +// https://github.com/remarkjs/remark-gfm/issues/16,解决某些 text 节点没有 position 的问题 +gfmAutolinkLiteralFromMarkdown.transforms = []; const depsLink = remark() .use(frontmatter) + .use(remarkGfm) .use(remarkDirective) .use(remarkMath); -// Manually register GFM extensions (without autolink literals to avoid false positives) -const data = depsLink.data(); -data.micromarkExtensions = data.micromarkExtensions || []; -data.micromarkExtensions.push(gfmExtension); -data.fromMarkdownExtensions = data.fromMarkdownExtensions || []; -data.fromMarkdownExtensions.push( - gfmFootnoteFromMarkdown(), - gfmStrikethroughFromMarkdown(), - gfmTableFromMarkdown(), - gfmTaskListItemFromMarkdown(), -); -data.toMarkdownExtensions = data.toMarkdownExtensions || []; -data.toMarkdownExtensions.push( - gfmFootnoteToMarkdown(), - gfmStrikethroughToMarkdown(), - gfmTableToMarkdown(), - gfmTaskListItemToMarkdown(), -); - /** * 将 Markdown 解析成 ast * From 4cc6897bf5bf4005646c3124c7e6ef371acaf1eb Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 16 Jun 2026 15:50:42 +0800 Subject: [PATCH 5/5] revert(deps): rollback jest to 27, keep typescript 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - jest 29→27, ts-jest 29→27, @types/jest 29→26 - Restore original snapshot format (Object/Array) - Only typescript 4→5 upgrade remains --- __tests__/__snapshots__/index.spec.ts.snap | 254 ++++++++++----------- package.json | 6 +- 2 files changed, 130 insertions(+), 130 deletions(-) diff --git a/__tests__/__snapshots__/index.spec.ts.snap b/__tests__/__snapshots__/index.spec.ts.snap index 2852563..8b2bdf1 100644 --- a/__tests__/__snapshots__/index.spec.ts.snap +++ b/__tests__/__snapshots__/index.spec.ts.snap @@ -1,16 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`test lint-md-parser invoke parseMd 1`] = ` -{ - "children": [ - { - "position": { - "end": { +Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 4, "line": 8, "offset": 68, }, - "start": { + "start": Object { "column": 1, "line": 1, "offset": 0, @@ -24,16 +24,16 @@ tags: - IDEA - Spring Boot", }, - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 14, "line": 10, "offset": 83, }, - "start": { + "start": Object { "column": 3, "line": 10, "offset": 72, @@ -44,13 +44,13 @@ tags: }, ], "depth": 1, - "position": { - "end": { + "position": Object { + "end": Object { "column": 14, "line": 10, "offset": 83, }, - "start": { + "start": Object { "column": 1, "line": 10, "offset": 70, @@ -58,16 +58,16 @@ tags: }, "type": "heading", }, - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 6, "line": 12, "offset": 90, }, - "start": { + "start": Object { "column": 1, "line": 12, "offset": 85, @@ -77,13 +77,13 @@ tags: "value": "你好 世界", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 6, "line": 12, "offset": 90, }, - "start": { + "start": Object { "column": 1, "line": 12, "offset": 85, @@ -91,18 +91,18 @@ tags: }, "type": "paragraph", }, - { - "children": [ - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 16, "line": 14, "offset": 107, }, - "start": { + "start": Object { "column": 1, "line": 14, "offset": 92, @@ -112,13 +112,13 @@ tags: "value": "www.example.com", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 16, "line": 14, "offset": 107, }, - "start": { + "start": Object { "column": 1, "line": 14, "offset": 92, @@ -128,14 +128,14 @@ tags: "type": "link", "url": "http://www.example.com", }, - { - "position": { - "end": { + Object { + "position": Object { + "end": Object { "column": 18, "line": 14, "offset": 109, }, - "start": { + "start": Object { "column": 16, "line": 14, "offset": 107, @@ -144,16 +144,16 @@ tags: "type": "text", "value": ", ", }, - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 37, "line": 14, "offset": 128, }, - "start": { + "start": Object { "column": 18, "line": 14, "offset": 109, @@ -163,13 +163,13 @@ tags: "value": "https://example.com", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 37, "line": 14, "offset": 128, }, - "start": { + "start": Object { "column": 18, "line": 14, "offset": 109, @@ -179,14 +179,14 @@ tags: "type": "link", "url": "https://example.com", }, - { - "position": { - "end": { + Object { + "position": Object { + "end": Object { "column": 43, "line": 14, "offset": 134, }, - "start": { + "start": Object { "column": 37, "line": 14, "offset": 128, @@ -195,16 +195,16 @@ tags: "type": "text", "value": ", and ", }, - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 62, "line": 14, "offset": 153, }, - "start": { + "start": Object { "column": 43, "line": 14, "offset": 134, @@ -214,13 +214,13 @@ tags: "value": "contact@example.com", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 62, "line": 14, "offset": 153, }, - "start": { + "start": Object { "column": 43, "line": 14, "offset": 134, @@ -230,14 +230,14 @@ tags: "type": "link", "url": "mailto:contact@example.com", }, - { - "position": { - "end": { + Object { + "position": Object { + "end": Object { "column": 63, "line": 14, "offset": 154, }, - "start": { + "start": Object { "column": 62, "line": 14, "offset": 153, @@ -247,13 +247,13 @@ tags: "value": ".", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 63, "line": 14, "offset": 154, }, - "start": { + "start": Object { "column": 1, "line": 14, "offset": 92, @@ -261,18 +261,18 @@ tags: }, "type": "paragraph", }, - { - "children": [ - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 16, "line": 16, "offset": 171, }, - "start": { + "start": Object { "column": 7, "line": 16, "offset": 162, @@ -282,13 +282,13 @@ tags: "value": "Big note.", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 16, "line": 16, "offset": 171, }, - "start": { + "start": Object { "column": 7, "line": 16, "offset": 162, @@ -299,13 +299,13 @@ tags: ], "identifier": "1", "label": "1", - "position": { - "end": { + "position": Object { + "end": Object { "column": 16, "line": 16, "offset": 171, }, - "start": { + "start": Object { "column": 1, "line": 16, "offset": 156, @@ -313,18 +313,18 @@ tags: }, "type": "footnoteDefinition", }, - { - "children": [ - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 5, "line": 18, "offset": 177, }, - "start": { + "start": Object { "column": 2, "line": 18, "offset": 174, @@ -334,13 +334,13 @@ tags: "value": "one", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 6, "line": 18, "offset": 178, }, - "start": { + "start": Object { "column": 1, "line": 18, "offset": 173, @@ -348,14 +348,14 @@ tags: }, "type": "delete", }, - { - "position": { - "end": { + Object { + "position": Object { + "end": Object { "column": 10, "line": 18, "offset": 182, }, - "start": { + "start": Object { "column": 6, "line": 18, "offset": 178, @@ -364,16 +364,16 @@ tags: "type": "text", "value": " or ", }, - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 15, "line": 18, "offset": 187, }, - "start": { + "start": Object { "column": 12, "line": 18, "offset": 184, @@ -383,13 +383,13 @@ tags: "value": "two", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 17, "line": 18, "offset": 189, }, - "start": { + "start": Object { "column": 10, "line": 18, "offset": 182, @@ -397,14 +397,14 @@ tags: }, "type": "delete", }, - { - "position": { - "end": { + Object { + "position": Object { + "end": Object { "column": 25, "line": 18, "offset": 197, }, - "start": { + "start": Object { "column": 17, "line": 18, "offset": 189, @@ -414,13 +414,13 @@ tags: "value": " tildes.", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 25, "line": 18, "offset": 197, }, - "start": { + "start": Object { "column": 1, "line": 18, "offset": 173, @@ -428,32 +428,32 @@ tags: }, "type": "paragraph", }, - { - "children": [ - { - "position": { - "end": { + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { "column": 78, "line": 20, "offset": 276, }, - "start": { + "start": Object { "column": 1, "line": 20, "offset": 199, }, }, "type": "text", - "value": "假设你打开了浏览器,并且搜索了 "www.google.com"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。", + "value": "假设你打开了浏览器,并且搜索了 \\"www.google.com\\"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 78, "line": 20, "offset": 276, }, - "start": { + "start": Object { "column": 1, "line": 20, "offset": 199, @@ -462,13 +462,13 @@ tags: "type": "paragraph", }, ], - "position": { - "end": { + "position": Object { + "end": Object { "column": 1, "line": 21, "offset": 277, }, - "start": { + "start": Object { "column": 1, "line": 1, "offset": 0, @@ -498,6 +498,6 @@ tags: ~~one~~ or ~~two~~ tildes. -假设你打开了浏览器,并且搜索了 "www\\.google.com"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。 +假设你打开了浏览器,并且搜索了 \\"www\\\\.google.com\\"。 在这个场景内,你的浏览器就是客户端,更宽泛地讲,你可以把你正在使用的计算机当作客户端。 " `; diff --git a/package.json b/package.json index baca777..4922650 100644 --- a/package.json +++ b/package.json @@ -27,15 +27,15 @@ "devDependencies": { "@attachments/eslint-config": "^0.3.3", "@microsoft/api-extractor": "^7.23.2", - "@types/jest": "^29.0.0", + "@types/jest": "^26.0.24", "@types/node": "^20.0.0", "concurrently": "^7.1.0", "eslint": "^8.57.0", - "jest": "^29.0.0", + "jest": "^27.0.6", "npm-run-all": "^4.1.5", "rimraf": "^3.0.2", "terser-webpack-plugin": "^5.3.1", - "ts-jest": "^29.0.0", + "ts-jest": "^27.0.4", "ts-loader": "^9.3.0", "ts-node": "^10.1.0", "typescript": "^5.0.0",