Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/x-markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dompurify": "^3.2.6",
"html-react-parser": "^5.2.13",
"katex": "^0.16.22",
"marked": "^15.0.12"
"marked": "^18.0.7"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
test_file="$repo_root/packages/x-markdown/src/XMarkdown/__tests__/Parser.test.ts"

rg -n '123 foo bar \(~123\)|<del>123 foo bar' "$test_file"

cd "$repo_root"
if [ -f pnpm-lock.yaml ]; then
  pnpm --dir packages/x-markdown test
elif [ -f yarn.lock ]; then
  yarn --cwd packages/x-markdown test
else
  npm --prefix packages/x-markdown test
fi

Repository: ant-design/x

Length of output: 150


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- package manifest ---'
sed -n '1,120p' packages/x-markdown/package.json

printf '%s\n' '--- parser test structure and target references ---'
ast-grep outline packages/x-markdown/src/XMarkdown/__tests__/Parser.test.ts
rg -n -C 3 'strikethrough|tilde|del|newline|custom|tag|123 foo bar' \
  packages/x-markdown/src/XMarkdown/__tests__/Parser.test.ts || true

printf '%s\n' '--- dependency declarations and lock entries ---'
rg -n -C 2 '"marked"|marked@|marked:' \
  packages/x-markdown/package.json package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null || true

printf '%s\n' '--- repository status and available package scripts ---'
git status --short
node -e 'const p=require("./packages/x-markdown/package.json"); console.log(JSON.stringify(p.scripts,null,2))'

Repository: ant-design/x

Length of output: 8896


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- tracked lockfiles ---'
git ls-files | rg '(^|/)(pnpm-lock\.yaml|yarn\.lock|package-lock\.json|bun\.lockb?)$' || true

printf '%s\n' '--- parser implementation and marked usage ---'
rg -n -C 5 'from .*(marked|Parser)|marked\(|parse\(|markedConfig|protectCustomTagNewlines|paragraphTag' \
  packages/x-markdown/src/XMarkdown packages/x-markdown/src 2>/dev/null | head -n 260

printf '%s\n' '--- complete parser test file ---'
cat -n packages/x-markdown/src/XMarkdown/__tests__/Parser.test.ts

printf '%s\n' '--- package workspace context ---'
sed -n '1,180p' package.json

Repository: ant-design/x

Length of output: 38548


🌐 Web query:

marked 18.0.0 release breaking change trailing blank lines 18.0.7 tilde interrupt regex fix

💡 Result:

In the marked library, version 18.0.0 introduced a breaking change that trims trailing blank lines from block tokens [1][2][3]. Additionally, version 18.0.7 included a fix to avoid O(n^2) backtracking in the HTML block close and tilde interrupt regexes [4][5], addressing potential ReDoS (Regular Expression Denial of Service) vulnerabilities [6][5].

Citations:


🌐 Web query:

marked 18.0.7 parse "~123 foo bar (~123)~" output

💡 Result:

In marked version 18.0.7, the syntax ~123 is treated as standard text unless specifically configured otherwise, as marked does not implement strikethrough (typically denoted by ~~text~~) or other tilde-based formatting by default without extensions or specific configurations [1][2]. Regarding your specific input ~123 foo bar (~123)~, marked 18.0.7 will parse this as plain text wrapped in paragraph tags, resulting in output similar to <p>~123 foo bar (~123)~</p>. It is worth noting that version 18.0.7 included specific bug fixes related to tilde characters, specifically: - Avoidance of O(n^2) backtracking in tilde interrupt regexes [3][4]. - Preservation of code spans adjacent to tildes [3][4]. These updates ensure that the parser handles tildes more efficiently and correctly in contexts where they might interact with other markdown elements, but they do not change the default behavior of treating single tildes as literal characters [3][4].

Citations:


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- local dependency availability ---'
node -e 'try { console.log(require.resolve("marked")); } catch (e) { console.log("marked is not installed"); }'

printf '%s\n' '--- marked package metadata from the registry ---'
curl -fsSL https://registry.npmjs.org/marked/18.0.7 |
  node -e '
    let s = "";
    process.stdin.on("data", d => s += d);
    process.stdin.on("end", () => {
      const p = JSON.parse(s);
      console.log(JSON.stringify({
        version: p.version,
        engines: p.engines,
        exports: p.exports,
        dist: p.dist && { tarball: p.dist.tarball, integrity: p.dist.integrity }
      }, null, 2));
    });
  '

printf '%s\n' '--- marked 18.0.7 strikethrough rule source ---'
curl -fsSL https://unpkg.com/marked@18.0.7/lib/marked.esm.js |
  rg -n -C 3 'tilde|del|~~|gfm' | head -n 120

Repository: ant-design/x

Length of output: 37196


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

node - <<'JS'
const versions = ['15.0.12', '18.0.7'];

for (const version of versions) {
  const source = await (await fetch(`https://unpkg.com/marked@${version}/lib/marked.esm.js`)).text();
  const module = await import(`data:text/javascript,${encodeURIComponent(source)}`);
  const marked = module.marked ?? module.default;

  const input = '~123 foo bar (~123)~';
  const result = marked(input);
  console.log(JSON.stringify({ version, input, result }));

  if (version === '18.0.7' && !result.includes('<del>123 foo bar (~123)</del>')) {
    process.exitCode = 1;
  }
}
JS

Repository: ant-design/x

Length of output: 518


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- tilde and strikethrough handling in the package ---'
rg -n -C 4 'strikethrough|strike|tilde|~~|~123|markedConfig|Tokenizer|del\(' \
  packages/x-markdown packages 2>/dev/null | head -n 260

printf '%s\n' '--- Parser constructor and configuration ---'
sed -n '1,130p' packages/x-markdown/src/XMarkdown/core/Parser.ts

printf '%s\n' '--- Parser preprocessing and parse path ---'
sed -n '250,375p' packages/x-markdown/src/XMarkdown/core/Parser.ts

Repository: ant-design/x

Length of output: 29747


不要仅升级 marked,请修复目标输入的解析行为。

marked@18.0.7~123 foo bar (~123)~ 的输出为 <p>~123 foo bar (<del>123)</del></p>\n。如果必须输出 <del>123 foo bar (~123)</del>,请增加自定义 tokenizer 或预处理逻辑,并添加回归测试。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/x-markdown/package.json` at line 60, 不要仅升级 marked;在项目现有的 Markdown
解析入口增加自定义 tokenizer 或预处理逻辑,使输入 ~123 foo bar (~123)~ 输出为 <del>123 foo bar
(~123)</del>。补充覆盖该输入与期望 HTML 的回归测试,并保留其他删除线语法的现有解析行为。

},
"devDependencies": {
"@playwright/experimental-ct-react": "^1.56.1",
Expand Down