fix(slides): improve text overflow and roundtrip linting#1963
Conversation
📝 WalkthroughWalkthroughThe XML linter now handles tag-specific roundtrip attributes, preserves paragraph breaks and spacing metadata, reads formatting from inner content elements, and reports likely text overflow. XML reference examples add auto-fit and wrapping attributes, with expanded validation and diagnostic tests. ChangesXML text linting and documentation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant XMLShape
participant lint_slide
participant detect_text_may_overflow_shapes
participant SlideIssues
XMLShape->>lint_slide: extracted text and paragraph metadata
lint_slide->>detect_text_may_overflow_shapes: text shapes
detect_text_may_overflow_shapes->>SlideIssues: text_may_overflow_shape warnings
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1963 +/- ##
==========================================
+ Coverage 74.98% 75.00% +0.01%
==========================================
Files 896 898 +2
Lines 94403 94912 +509
==========================================
+ Hits 70789 71184 +395
- Misses 18198 18269 +71
- Partials 5416 5459 +43 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@8dba8e3b352ba4807ad85b24fc6bed526322e04d🧩 Skill updatenpx skills add larksuite/cli#codex/text-shape-overflow-pr -y -g |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with 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.
Inline comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 677-679: Update the fontSize extraction in the element
construction logic to use extract_numeric_attribute instead of directly
converting the selected attribute with float(). Preserve the existing precedence
between content_attrs and attrs, and retain 16 as the fallback when no numeric
value can be parsed so non-numeric fontSize values do not abort linting.
- Around line 811-813: Update the estimated-height calculation in the
paragraph-processing logic to use line_height for the first line as well as
subsequent lines, replacing the font_size contribution while preserving
before_spacing, after_spacing, and paragraph line-count handling. Ensure
multi-paragraph text advances by the full line_height and produces the expected
overflow warning.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6b999786-052f-437f-a2f1-cbe54b20b40d
📒 Files selected for processing (4)
skills/lark-slides/references/xml-format-guide.mdskills/lark-slides/references/xml-schema-quick-ref.mdskills/lark-slides/scripts/xml_text_overlap_lint.pyskills/lark-slides/scripts/xml_text_overlap_lint_test.py
08ee29c to
f339ba7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with 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.
Inline comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 665-681: Update the text-height extraction around the element
update and its fontSize calculation to inspect inline span fontSize values
within each paragraph, carry the maximum discovered span size forward, and use
it before the content/shape fallback and default of 16. Preserve existing
behavior when no inline span specifies a valid font size.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e9f02fc7-d899-4d22-9030-9cb7992db0e1
📒 Files selected for processing (3)
skills/lark-slides/references/xml-schema-quick-ref.mdskills/lark-slides/scripts/xml_text_overlap_lint.pyskills/lark-slides/scripts/xml_text_overlap_lint_test.py
🚧 Files skipped from review as they are similar to previous changes (2)
- skills/lark-slides/references/xml-schema-quick-ref.md
- skills/lark-slides/scripts/xml_text_overlap_lint_test.py
f339ba7 to
8dba8e3
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
skills/lark-slides/scripts/xml_text_overlap_lint.py (1)
665-682: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftfontSize still not read from inline
<span fontSize="...">.
fontSizeis only sourced from<content fontSize>then shape-levelattrs; inline<span fontSize="...">inside<p>is still dropped, defaulting to 16. This is a repeat of a prior review comment and is now more consequential: the newdetect_text_may_overflow_shapesoverflow estimator depends onelement["fontSize"], and this file's own fixture samples (image-led-cover,content-grid, lines 45-73) exclusively use span-levelfontSize(e.g.<span fontSize="42">) with no content-level fallback — so overflow detection will silently use the wrong font size for this common authoring pattern.🛡️ Suggested approach
- content_attrs = extract_tag_attributes(content, "content") - font_size = extract_numeric_attribute(content_attrs, "fontSize") - if font_size is None: - font_size = extract_numeric_attribute(attrs, "fontSize") + content_attrs = extract_tag_attributes(content, "content") + font_size = extract_numeric_attribute(content_attrs, "fontSize") + if font_size is None: + font_size = extract_numeric_attribute(attrs, "fontSize") + if font_size is None: + span_font_sizes = [ + extract_numeric_attribute(span_attrs, "fontSize") + for span_attrs in re.findall(r"<span\b([^>]*)>", content) + ] + span_font_sizes = [size for size in span_font_sizes if size is not None] + if span_font_sizes: + font_size = max(span_font_sizes)🤖 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 `@skills/lark-slides/scripts/xml_text_overlap_lint.py` around lines 665 - 682, Update the fontSize extraction in the element-building flow around extract_tag_attributes and element.update to inspect inline span fontSize values within the paragraph content before falling back to content-level and shape-level attributes. Ensure span-level fontSize populates element["fontSize"] for samples without higher-level values, while retaining the existing fallback to 16 when no font size is available.
🤖 Prompt for all review comments with 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.
Duplicate comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 665-682: Update the fontSize extraction in the element-building
flow around extract_tag_attributes and element.update to inspect inline span
fontSize values within the paragraph content before falling back to
content-level and shape-level attributes. Ensure span-level fontSize populates
element["fontSize"] for samples without higher-level values, while retaining the
existing fallback to 16 when no font size is available.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f8d26a0e-1420-40af-8301-c7a872b83baa
📒 Files selected for processing (3)
skills/lark-slides/references/xml-schema-quick-ref.mdskills/lark-slides/scripts/xml_text_overlap_lint.pyskills/lark-slides/scripts/xml_text_overlap_lint_test.py
🚧 Files skipped from review as they are similar to previous changes (1)
- skills/lark-slides/references/xml-schema-quick-ref.md
Summary
Improve Slides XML linting for text-shape overflow while avoiding false positives from server-filled chart roundtrip attributes.
Changes
text_may_overflow_shapewarning when content may exceed its box.chart.updatedandchartData.isStaticDatafrom SXSD attribute validation because they are populated during server roundtrips.Test Plan
git diff --check origin/main...HEADorigin/mainRelated Issues
Summary by CodeRabbit
autoFitandwrapsettings.<br/>breaks, and attribute validation scenarios.