Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yanghuanrong
Copy link
Contributor

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

💡 Background and Solution

  • 通过 protectCustomTagNewlines 来配置在自定义组件中支持\n\n

📝 Change Log

Language Changelog
🇺🇸 English enhance XMarkdown parser to support custom components with placeholder protection
🇨🇳 Chinese 增强 XMarkdown 解析器,使其支持带占位符保护的自定义组件。

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

Preview is ready

@dosubot dosubot bot added the enhancement New feature or request label Jan 19, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yanghuanrong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a parsing inconsistency where newlines within custom components in XMarkdown might be inadvertently removed or altered. By introducing a configurable option, the parser can now intelligently preserve these newlines using a placeholder strategy, ensuring that custom components render as intended without losing their structural formatting.

Highlights

  • New Configuration Option: Introduced a new protectCustomTagNewlines boolean option in XMarkdownProps and ParserOptions to control whether newlines within custom tags should be protected during parsing.
  • Newline Protection Mechanism: Implemented a mechanism to temporarily replace double newlines (\n\n) found within custom HTML-like tags with unique placeholders before the markdown parsing process. These placeholders are then restored to their original newlines after parsing, ensuring correct rendering.
  • Parser Integration: The Parser class now conditionally applies the newline protection and restoration logic based on the protectCustomTagNewlines option, enhancing its ability to handle custom components without unintended newline stripping.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new feature to protect newlines within custom tags in XMarkdown, preventing them from being interpreted as paragraph breaks. This is achieved by temporarily replacing double newlines with placeholders before parsing and then restoring them. The implementation in Parser.ts is quite comprehensive.

My review identified a potential issue with how self-closing custom tags are handled, which could lead to incorrect parsing. I've also suggested a couple of minor refactorings to improve the readability and maintainability of the new parsing logic. Overall, this is a valuable addition.

Comment on lines +134 to +143
match = openTagRegex.exec(content);
while (match !== null) {
positions.push({
index: match.index,
type: 'open',
tagName: match[1].toLowerCase(),
match: match[0],
});
match = openTagRegex.exec(content);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The while loop for finding open tags can be simplified by combining the assignment and the condition. This makes the code more concise and easier to read, avoiding the repetition of openTagRegex.exec(content).

    while ((match = openTagRegex.exec(content))) {
      positions.push({
        index: match.index,
        type: 'open',
        tagName: match[1].toLowerCase(),
        match: match[0],
      });
    }

Comment on lines +146 to +155
match = closeTagRegex.exec(content);
while (match !== null) {
positions.push({
index: match.index,
type: 'close',
tagName: match[1].toLowerCase(),
match: match[0],
});
match = closeTagRegex.exec(content);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the loop for open tags, this while loop for finding close tags can be simplified. Combining the assignment and condition makes the code more concise and readable.

    while ((match = closeTagRegex.exec(content))) {
      positions.push({
        index: match.index,
        type: 'close',
        tagName: match[1].toLowerCase(),
        match: match[0],
      });
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

赋值不应出现在表达式中

@Div627
Copy link
Contributor

Div627 commented Jan 20, 2026

@yanghuanrong Hi,该合并有冲突需要解决

@yanghuanrong
Copy link
Contributor Author

@yanghuanrong Hi,该合并有冲突需要解决

@Div627 已经处理了

@codecov
Copy link

codecov bot commented Jan 20, 2026

Bundle Report

Changes will increase total bundle size by 1.25MB (66.57%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
x-markdown-array-push 1.37MB 1.25MB (1063.05%) ⬆️⚠️

Affected Assets, Files, and Routes:

view changes for bundle: x-markdown-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
latex.min.js (New) 268.81kB 268.81kB 100.0% 🚀
static/KaTeX_AMS-Regular.*.ttf (New) 63.63kB 63.63kB 100.0% 🚀
static/KaTeX_Main-Regular.*.ttf (New) 53.58kB 53.58kB 100.0% 🚀
static/KaTeX_Main-Bold.*.ttf (New) 51.34kB 51.34kB 100.0% 🚀
static/KaTeX_Main-Italic.*.ttf (New) 33.58kB 33.58kB 100.0% 🚀
static/KaTeX_AMS-Regular.*.woff (New) 33.52kB 33.52kB 100.0% 🚀
static/KaTeX_Main-BoldItalic.*.ttf (New) 32.97kB 32.97kB 100.0% 🚀
static/KaTeX_Math-Italic.*.ttf (New) 31.31kB 31.31kB 100.0% 🚀
static/KaTeX_Math-BoldItalic.*.ttf (New) 31.2kB 31.2kB 100.0% 🚀
static/KaTeX_Main-Regular.*.woff (New) 30.77kB 30.77kB 100.0% 🚀
static/KaTeX_Main-Bold.*.woff (New) 29.91kB 29.91kB 100.0% 🚀
static/KaTeX_AMS-Regular.*.woff2 (New) 28.08kB 28.08kB 100.0% 🚀
static/KaTeX_Typewriter-Regular.*.ttf (New) 27.56kB 27.56kB 100.0% 🚀
static/KaTeX_Main-Regular.*.woff2 (New) 26.27kB 26.27kB 100.0% 🚀
static/KaTeX_Main-Bold.*.woff2 (New) 25.32kB 25.32kB 100.0% 🚀
static/KaTeX_SansSerif-Bold.*.ttf (New) 24.5kB 24.5kB 100.0% 🚀
latex.min.css (New) 24.32kB 24.32kB 100.0% 🚀
static/KaTeX_SansSerif-Italic.*.ttf (New) 22.36kB 22.36kB 100.0% 🚀
static/KaTeX_Main-Italic.*.woff (New) 19.68kB 19.68kB 100.0% 🚀
static/KaTeX_Fraktur-Bold.*.ttf (New) 19.58kB 19.58kB 100.0% 🚀
static/KaTeX_Fraktur-Regular.*.ttf (New) 19.57kB 19.57kB 100.0% 🚀
static/KaTeX_SansSerif-Regular.*.ttf (New) 19.44kB 19.44kB 100.0% 🚀
static/KaTeX_Main-BoldItalic.*.woff (New) 19.41kB 19.41kB 100.0% 🚀
static/KaTeX_Math-Italic.*.woff (New) 18.75kB 18.75kB 100.0% 🚀
static/KaTeX_Math-BoldItalic.*.woff (New) 18.67kB 18.67kB 100.0% 🚀
static/KaTeX_Main-Italic.*.woff2 (New) 16.99kB 16.99kB 100.0% 🚀
static/KaTeX_Main-BoldItalic.*.woff2 (New) 16.78kB 16.78kB 100.0% 🚀
static/KaTeX_Script-Regular.*.ttf (New) 16.65kB 16.65kB 100.0% 🚀
static/KaTeX_Math-Italic.*.woff2 (New) 16.44kB 16.44kB 100.0% 🚀
static/KaTeX_Math-BoldItalic.*.woff2 (New) 16.4kB 16.4kB 100.0% 🚀
static/KaTeX_Typewriter-Regular.*.woff (New) 16.03kB 16.03kB 100.0% 🚀
static/KaTeX_SansSerif-Bold.*.woff (New) 14.41kB 14.41kB 100.0% 🚀
static/KaTeX_SansSerif-Italic.*.woff (New) 14.11kB 14.11kB 100.0% 🚀
static/KaTeX_Typewriter-Regular.*.woff2 (New) 13.57kB 13.57kB 100.0% 🚀
static/KaTeX_Fraktur-Bold.*.woff (New) 13.3kB 13.3kB 100.0% 🚀
static/KaTeX_Fraktur-Regular.*.woff (New) 13.21kB 13.21kB 100.0% 🚀
static/KaTeX_Caligraphic-Bold.*.ttf (New) 12.37kB 12.37kB 100.0% 🚀
static/KaTeX_Caligraphic-Regular.*.ttf (New) 12.34kB 12.34kB 100.0% 🚀
static/KaTeX_SansSerif-Regular.*.woff (New) 12.32kB 12.32kB 100.0% 🚀
static/KaTeX_Size1-Regular.*.ttf (New) 12.23kB 12.23kB 100.0% 🚀
static/KaTeX_SansSerif-Bold.*.woff2 (New) 12.22kB 12.22kB 100.0% 🚀
static/KaTeX_SansSerif-Italic.*.woff2 (New) 12.03kB 12.03kB 100.0% 🚀
static/KaTeX_Size2-Regular.*.ttf (New) 11.51kB 11.51kB 100.0% 🚀
static/KaTeX_Fraktur-Bold.*.woff2 (New) 11.35kB 11.35kB 100.0% 🚀
static/KaTeX_Fraktur-Regular.*.woff2 (New) 11.32kB 11.32kB 100.0% 🚀
static/KaTeX_Script-Regular.*.woff (New) 10.59kB 10.59kB 100.0% 🚀
static/KaTeX_Size4-Regular.*.ttf (New) 10.36kB 10.36kB 100.0% 🚀
static/KaTeX_SansSerif-Regular.*.woff2 (New) 10.34kB 10.34kB 100.0% 🚀
static/KaTeX_Script-Regular.*.woff2 (New) 9.64kB 9.64kB 100.0% 🚀
static/KaTeX_Caligraphic-Bold.*.woff (New) 7.72kB 7.72kB 100.0% 🚀
static/KaTeX_Caligraphic-Regular.*.woff (New) 7.66kB 7.66kB 100.0% 🚀
static/KaTeX_Size3-Regular.*.ttf (New) 7.59kB 7.59kB 100.0% 🚀
static/KaTeX_Caligraphic-Bold.*.woff2 (New) 6.91kB 6.91kB 100.0% 🚀
static/KaTeX_Caligraphic-Regular.*.woff2 (New) 6.91kB 6.91kB 100.0% 🚀
static/KaTeX_Size1-Regular.*.woff (New) 6.5kB 6.5kB 100.0% 🚀
static/KaTeX_Size2-Regular.*.woff (New) 6.19kB 6.19kB 100.0% 🚀
static/KaTeX_Size4-Regular.*.woff (New) 5.98kB 5.98kB 100.0% 🚀
static/KaTeX_Size1-Regular.*.woff2 (New) 5.47kB 5.47kB 100.0% 🚀
static/KaTeX_Size2-Regular.*.woff2 (New) 5.21kB 5.21kB 100.0% 🚀
static/KaTeX_Size4-Regular.*.woff2 (New) 4.93kB 4.93kB 100.0% 🚀
static/KaTeX_Size3-Regular.*.woff (New) 4.42kB 4.42kB 100.0% 🚀
static/KaTeX_Size3-Regular.*.woff2 (New) 3.62kB 3.62kB 100.0% 🚀
x-markdown.min.js (Deleted) -111.4kB 0 bytes -100.0% 🗑️
x-markdown.min.css (Deleted) -6.36kB 0 bytes -100.0% 🗑️

@Div627
Copy link
Contributor

Div627 commented Jan 21, 2026

@yanghuanrong Hi,为了确保功能的稳定性和可维护性,建议补充相应的测试用例,覆盖核心逻辑,以防止后续变更导致回归问题。

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.30%. Comparing base (031535f) to head (e178e93).
⚠️ Report is 14 commits behind head on feature.

Additional details and impacted files
@@             Coverage Diff             @@
##           feature    #1668      +/-   ##
===========================================
+ Coverage    97.24%   97.30%   +0.05%     
===========================================
  Files          144      144              
  Lines         4501     4564      +63     
  Branches      1273     1287      +14     
===========================================
+ Hits          4377     4441      +64     
+ Misses         122      121       -1     
  Partials         2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yanghuanrong
Copy link
Contributor Author

@yanghuanrong Hi,为了确保功能的稳定性和可维护性,建议补充相应的测试用例,覆盖核心逻辑,以防止后续变更导致回归问题。

@Div627 感谢你的指导。

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 21, 2026
@Div627 Div627 merged commit d7100bc into ant-design:feature Jan 21, 2026
11 checks passed
@github-actions
Copy link
Contributor

🎉 Thank you for your contribution! If you have not yet joined our DingTalk community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您还没有加入钉钉社区群,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants