feat: copy compare table as markdown#1533
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughIntroduces a new CopyToClipboardButton Vue component (script setup, TypeScript) and integrates it across package and compare pages. Adds client-side HTML→Markdown conversion and clipboard copy for comparison grids, including a new html-to-markdown utility and five AST/parse dependencies. Moves escapeHtml into a shared utility and updates imports/tests. Adds i18n keys/translations and accessibility tests for the new component. Several ad‑hoc floating copy buttons and related styles are replaced by the new component. Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
server/utils/docs/text.ts (1)
121-124: Avoid the non‑null assertion on array indexing.The guideline calls for explicit checks when indexing arrays; this avoids
!and keeps the code strictly type‑safe.♻️ Suggested fix
- for (let i = 0; i < codeBlockData.length; i++) { - const { lang, code } = codeBlockData[i]! + for (let i = 0; i < codeBlockData.length; i++) { + const entry = codeBlockData[i] + if (!entry) continue + const { lang, code } = entry const highlighted = await highlightCodeBlock(code, lang) result = result.replace(`__CODE_BLOCK_${i}__`, highlighted) }As per coding guidelines, "Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index".
app/pages/compare.vue (1)
95-100: Consider adding a type guard for safer array access.Accessing
children[0]at line 97 could returnundefinedif the grid has no children. While line 100 handles the falsy case, TypeScript may not narrow the type correctly. The current logic works but could be made more explicit.Proposed defensive check
function gridToMarkdown(gridEl: HTMLElement): string { const children = Array.from(gridEl.children) - const headerRow = children[0] + const headerRow = children[0] as Element | undefined const dataRows = children.slice(1) if (!headerRow || dataRows.length === 0) return ''app/components/CopyToClipboardButton.vue (1)
51-83: Consider adding graceful degradation for older browsers withoutallow-discretesupport.The
allow-discretetransitions are well-supported across modern browsers (Chrome 117+, Safari 17.4+, Firefox 129+), but this is a feature projected to reach "Baseline widely available" by February 2027. For enhanced compatibility with older browser versions, consider either removingallow-discretefrom production builds or implementing a progressive enhancement strategy. Without it, transitions become discrete jumps rather than smooth animations—the component remains functional, but the visual refinement is lost.
Implements #1515
Packages used for html to markdown util are dependencies that already were used in the project.
How it work:
Screencast_20260216_192439.mp4