Repository navigation
feat: email quality toolkit slice 1 — size, plain text, JSON trace, inspector polish - #49
Merged
Merged
Conversation
…nspector polish Implements the first slice of the quality toolkit from the uploaded patch: - measureSize: UTF-8 bytes, Gmail 102 KB clip risk, clipped parts, unsubscribe warning - toText: plain-text alternative from HTML (headings, lists, links, entities, wrap) - traceJson / traceJsonText and /trace.json + inspect --json - Inspector: size section, plain-text section, Light/Dark preview via withScheme, previous/next part navigation, select-all source - Subpath export @llazyemail/template-runtime-display/quality - CLI stability (no crash on closed stdout) Moves the inspector guide into docs/inspector.md, updates the quality toolkit status in docs/email-quality-toolkit.md, and removes the temporary source files. All tests pass with 100% coverage. Prettier clean.
Rendered emailsThis PR rendered email templates.
Open the run → Artifacts → download → open |
The previous /<[^>]*>/g could backtrack on inputs that start with '<' and contain many '<' without a matching '>'. The new implementation walks the string once with indexOf and keeps any unclosed tag as text, so it is linear and cannot loop.
…racter sanitization' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
ESLint no-irregular-whitespace flagged the raw U+00A0 inside the character class on the line that collapses runs of spaces. Use the explicit \\u00A0 escape so the source stays ASCII-clean and lint passes.
CodeQL flagged several polynomial regular expressions on library input and incomplete multi-character sanitization in src/quality/text.ts. - Comments, head/style/script pairs, and display:none blocks are now removed with linear indexOf scans. - Preheader extraction walks spans with indexOf instead of a backtracking regex. - Anchors and headings are rewritten with the same linear style. The previous do-while replace loop is gone. Behavior for well-formed email HTML is unchanged, and unclosed constructs no longer risk quadratic backtracking. Coverage remains 100%.
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
Applies the changes from the uploaded
toolkit-slice1-inspector-polish.patchand incorporatesinspector-guide.mdinto the docs.What landed
measureSize(result)— UTF-8 bytes, Gmail ~102 KB clip risk (ok/near/over), per-part sizes, clipped parts, unsubscribe-after-clip warning.toText(html)— headings → uppercase, lists →- item, links →label (url), entities decoded, preheader kept, styles/scripts dropped, wrap at 78 columns.traceJson/traceJsonText, served at/trace.jsonon the dev server, and written byinspect --json.color-schemeviawithScheme), previous/next part navigation, select-all on source blocks.@llazyemail/template-runtime-display/qualityexportsmeasureSize,toText,byteLength.| head).Docs
docs/inspector.md.docs/email-quality-toolkit.mdwith the shipped status for this slice.inspector-guide.mdand the patch).Tests
test/quality.test.tsandtest/polish.test.ts.Test plan
npm run checkpassesnpm run test:coverageshows 100%npx template-runtime-display inspect ./examples/inspect-demo.mjs --json trace.jsonwrites both the report and the JSON/trace.jsonCloses the temporary files that were added for this work. Next slices will add the linter and dark-mode contrast rules.