fix: 修复左侧导航菜单栏在部分页面不被翻译的问题#221
Open
Levitans wants to merge 1 commit into
Open
Conversation
根因:Mintlify 等文档框架将侧边栏放置在 <header> 标签内, 而 TreeWalker 的 FILTER_REJECT 会跳过 header 及其所有后代节点, 导致侧边栏内容完全不被遍历。 修改内容: 1. header/footer 的 FILTER_REJECT 改为 FILTER_SKIP,保留遍历子节点 2. 新增 containerSet 定义块级容器标签集合 3. isInlineElement 排除容器元素,避免向上穿透过多层级 4. grabNode 第6步扩展为 containerSet,统一容器元素处理逻辑
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts DOM traversal and element classification so header-contained navigation (e.g., Mintlify sidebars) are included in translation, while tightening inline/container handling to avoid over-aggressive parent merging. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Previously
grabNodehandled bothdivandlabelfor first-line text, but after switching tocontainerSetthelabeltag is no longer included, which may change behavior for labels; consider either addinglabeltocontainerSetor explicitly documenting this change in behavior. - Since
header/footerare now incontainerSet,isInlineElementwill never usedetectChildMetafor them even if they only contain inline children; double-check that this broader container classification forheader/footeris intentional and doesn’t cause unexpected skipping of inline-like regions.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Previously `grabNode` handled both `div` and `label` for first-line text, but after switching to `containerSet` the `label` tag is no longer included, which may change behavior for labels; consider either adding `label` to `containerSet` or explicitly documenting this change in behavior.
- Since `header`/`footer` are now in `containerSet`, `isInlineElement` will never use `detectChildMeta` for them even if they only contain inline children; double-check that this broader container classification for `header`/`footer` is intentional and doesn’t cause unexpected skipping of inline-like regions.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因:Mintlify 等文档框架将侧边栏放置在
标签内,而 TreeWalker 的 FILTER_REJECT 会跳过 header 及其所有后代节点,
导致侧边栏内容完全不被遍历。
修改内容:
Summary by Sourcery
Ensure DOM traversal correctly includes sidebar content nested under header/footer elements while refining handling of container and inline elements during translation.
Bug Fixes:
Enhancements: