refactor(render): Modularize SVG and HTML renderers and improve CJK label width estimation#47
Merged
Merged
Conversation
…mat!() in column loop - Replace the ASCII/non-ASCII binary heuristic in estimate_label_width with unicode-width's width_cjk(), giving correct widths for CJK, emoji, and other multi-cell characters. - Eliminate per-column String allocation in the column rendering loop by writing directly into the output buffer with write!() instead of building an intermediate String via format!().
…ecial characters Verify that user-supplied titles containing HTML injection payloads, ampersands, quotes, and apostrophes are properly escaped in both the <title> and <h1> elements of the generated HTML document.
Extract node rendering, column badges, label estimation, and overlay badge helpers into node.rs. Extract Crow's Foot inline marker rendering and sampling helpers into markers.rs. lib.rs shrinks from ~2500 to ~1900 lines and retains the public API, defs, edge rendering, and tests.
Extract the ~1460-line build_css function into css.rs and the HTML/JS component builders into components.rs. html.rs shrinks from ~2400 to ~700 lines and retains the document assembly logic and tests.
Code Metrics Report
Details | | main (c1721cb) | #47 (3baaae4) | +/- |
|---------------------|----------------|---------------|-------|
- | Coverage | 94.1% | 94.1% | -0.1% |
| Files | 73 | 77 | +4 |
| Lines | 29862 | 29895 | +33 |
+ | Covered | 28117 | 28148 | +31 |
- | Test Execution Time | 1m35s | 1m39s | +4s |Code coverage of files in pull request scope (98.2% → 98.2%)
Reported by octocov |
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.
Summary
unicode-widthforcorrect CJK and emoji rendering
elements
relune-render-svglib.rsintonode.rsandmarkers.rsto reduce file size andimprove maintainability
relune-render-htmlhtml.rsintocss.rsandcomponents.rsto separate concernsChanges
loop
estimate_label_widthwithunicode-width'swidth_cjk()for correct widths of CJK, emoji, and other multi-cell charactersStringallocation in the column rendering loop by writing directlyinto the output buffer with
write!()instead of building an intermediateStringviaformat!()apostrophes are properly escaped in both the
<title>and<h1>elementsnode.rsmarkers.rslib.rsshrinks from ~2500 to ~1900 lines, retaining the public API, defs, edge rendering,and tests
build_cssfunction intocss.rsand the HTML/JS component buildersinto
components.rshtml.rsshrinks from ~2400 to ~700 lines, retaining the document assembly logic and tests