mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-18 10:03:55 +00:00
fix: downgrade md lib (#4508)
downgrade mdast-util-gfm-autolink-literal to 2.0.0 to avoid patch missing
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
"./**/**/*.{ts,tsx,scss}": "npm run format-code",
|
||||
"./docSite/**/**/*.md": "npm run format-doc"
|
||||
},
|
||||
"resolutions": {
|
||||
"mdast-util-gfm-autolink-literal": "2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.16.0",
|
||||
"pnpm": ">=9.0.0"
|
||||
|
@@ -1,79 +0,0 @@
|
||||
diff --git a/lib/index.js b/lib/index.js
|
||||
index c5ca771c24dd914e342f791716a822431ee32b3a..457d9f8c4625f7d9c7ea1e9ffc13616db1fc6fef 100644
|
||||
--- a/lib/index.js
|
||||
+++ b/lib/index.js
|
||||
@@ -126,8 +126,37 @@ function exitLiteralAutolink(token) {
|
||||
this.exit(token)
|
||||
}
|
||||
|
||||
-/** @type {FromMarkdownTransform} */
|
||||
+// Regex support detector, for backward compatibility
|
||||
+// Ref: https://github.com/syntax-tree/mdast-util-gfm-autolink-literal/pull/14
|
||||
+const regexSupport = {
|
||||
+ lookbehind: (() => {
|
||||
+ try {
|
||||
+ // Using regex literal instead of RegExp constructor
|
||||
+ ;/(?<=x)/.test('x')
|
||||
+ return true
|
||||
+ } catch {
|
||||
+ return false
|
||||
+ }
|
||||
+ })()
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Main transform function that uses the appropriate version based on regex support
|
||||
+ * @type {FromMarkdownTransform}
|
||||
+ */
|
||||
function transformGfmAutolinkLiterals(tree) {
|
||||
+ if (regexSupport.lookbehind) {
|
||||
+ modernAutolinkTransform(tree)
|
||||
+ } else {
|
||||
+ legacyAutolinkTransform(tree)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Modern version of autolink transform using lookbehind
|
||||
+ * @type {FromMarkdownTransform}
|
||||
+ */
|
||||
+function modernAutolinkTransform(tree) {
|
||||
findAndReplace(
|
||||
tree,
|
||||
[
|
||||
@@ -138,6 +167,35 @@ function transformGfmAutolinkLiterals(tree) {
|
||||
)
|
||||
}
|
||||
|
||||
+
|
||||
+/**
|
||||
+ * Legacy version of autolink transform for older Node.js versions
|
||||
+ * @type {FromMarkdownTransform}
|
||||
+ */
|
||||
+function legacyAutolinkTransform(tree) {
|
||||
+ findAndReplace(
|
||||
+ tree,
|
||||
+ [
|
||||
+ [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
|
||||
+ // [/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g, findEmail] # NOTE: original regex in 2.0.0
|
||||
+ [/(^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmailLegacy]
|
||||
+ ],
|
||||
+ {ignore: ['link', 'linkReference']}
|
||||
+ )
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Helper function for legacy email matching
|
||||
+ * @param {string} _ - Unused parameter
|
||||
+ * @param {string} prefix - Email prefix
|
||||
+ * @param {string} name - Email name
|
||||
+ * @param {string} domain - Email domain
|
||||
+ * @returns {*} The processed email
|
||||
+ */
|
||||
+function findEmailLegacy(_, prefix, name, domain) {
|
||||
+ return findEmail(name + '@' + domain)
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* @type {ReplaceFunction}
|
||||
* @param {string} _
|
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@@ -4,10 +4,8 @@ settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
patchedDependencies:
|
||||
mdast-util-gfm-autolink-literal@2.0.1:
|
||||
hash: f63d515781110436299ab612306211a9621c6dfaec1ce1a19e2f27454dc70251
|
||||
path: patches/mdast-util-gfm-autolink-literal@2.0.1.patch
|
||||
overrides:
|
||||
mdast-util-gfm-autolink-literal: 2.0.0
|
||||
|
||||
importers:
|
||||
|
||||
@@ -6812,8 +6810,8 @@ packages:
|
||||
mdast-util-from-markdown@2.0.2:
|
||||
resolution: {integrity: sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==}
|
||||
|
||||
mdast-util-gfm-autolink-literal@2.0.1:
|
||||
resolution: {integrity: sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==}
|
||||
mdast-util-gfm-autolink-literal@2.0.0:
|
||||
resolution: {integrity: sha512-FyzMsduZZHSc3i0Px3PQcBT4WJY/X/RCtEJKuybiC6sjPqLv7h1yqAkmILZtuxMSsUyaLUWNp71+vQH2zqp5cg==}
|
||||
|
||||
mdast-util-gfm-footnote@2.1.0:
|
||||
resolution: {integrity: sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==}
|
||||
@@ -16941,7 +16939,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
mdast-util-gfm-autolink-literal@2.0.1:
|
||||
mdast-util-gfm-autolink-literal@2.0.0:
|
||||
dependencies:
|
||||
'@types/mdast': 4.0.4
|
||||
ccount: 2.0.1
|
||||
@@ -16989,7 +16987,7 @@ snapshots:
|
||||
mdast-util-gfm@3.1.0:
|
||||
dependencies:
|
||||
mdast-util-from-markdown: 2.0.2
|
||||
mdast-util-gfm-autolink-literal: 2.0.1
|
||||
mdast-util-gfm-autolink-literal: 2.0.0
|
||||
mdast-util-gfm-footnote: 2.1.0
|
||||
mdast-util-gfm-strikethrough: 2.0.0
|
||||
mdast-util-gfm-table: 2.0.0
|
||||
|
@@ -2,6 +2,3 @@ packages:
|
||||
- packages/*
|
||||
- projects/*
|
||||
- scripts/icon
|
||||
|
||||
patchedDependencies:
|
||||
mdast-util-gfm-autolink-literal@2.0.1: patches/mdast-util-gfm-autolink-literal@2.0.1.patch
|
||||
|
Reference in New Issue
Block a user