-
-
Notifications
You must be signed in to change notification settings - Fork 998
feat: add support for protecting newlines in custom tags in XMarkdown #1668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…holder protection
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit 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)
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. Comment |
Summary of ChangesHello @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 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 AssistThe 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
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 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
|
There was a problem hiding this 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.
| 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); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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],
});
}| 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); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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],
});
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赋值不应出现在表达式中
…lf-closing tags correctly
|
@yanghuanrong Hi,该合并有冲突需要解决 |
Signed-off-by: 杨焕荣 <[email protected]>
@Div627 已经处理了 |
Bundle ReportChanges will increase total bundle size by 1.25MB (66.57%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: x-markdown-array-pushAssets Changed:
|
|
@yanghuanrong Hi,为了确保功能的稳定性和可维护性,建议补充相应的测试用例,覆盖核心逻辑,以防止后续变更导致回归问题。 |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
@Div627 感谢你的指导。 |
…g newline behavior in custom tags

中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log