首页›Eric Meyer›文章

Custom Asidenotes

Eric Meyer · 2025年10月29日

AI 摘要 AI 生成,可能有误

作者对其先前的“asidenotes”(旁注)技术进行了改进——即将行内括号式的插语转换为页边旁注——具体做法是定义一个自定义 HTML 元素 ,并使用 JavaScript 自动插入标记、去除包裹的括号并追加句末标点。该脚本仅在浏览器支持 CSS 锚点定位(通过 CSS.supports 检测)且视口宽度至少为 65em(通过 matchMedia 检测)时才会运行,否则文本仍保持为普通的行内括号内容。鉴于这一方法已经在这篇文章本身中奏效,作者倾向于在 meyerweb 全站范围内采用它。

Previously on meyerweb, I crawled through a way to turn parenthetical comments into sidenotes, which I called “asidenotes”.  As a recap, these are inline asides in parentheses, which is something I like to do.  The constraints are that the text has to start inline, with its enclosing parentheses as part of the static content, so that the parentheses are present if CSS isn’t applied, but should lose those parentheses when turned into asidenotes, while also adding a sentence-terminating period when needed.

At the end of that post, I said I wouldn’t use the technique I developed, because the markup was too cluttered and unwieldy, and there were failure states that CSS alone couldn’t handle.  So what can we do instead?  Extend HTML to do things automatically!

If you’ve read my old post “Blinded By the DOM Light”, you can probably guess how this will go.  Basically, we can write a little bit of JavaScript to take an invented element and Do Things To It™.  What things?  Anything JavaScript makes possible.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Eric Meyer

My Interop 2027 Rankings

AI 摘要The author shares their personal rankings for Interop 2027 proposals using Jake Archibald's community ranking tool, placing JavaScript Temporal first, followed by improving CSS sibling-count()/sibling-index() interop, unprefixed CSS box-decoration-break, HTML headingoffset/headingreset attributes, and CSS line-clamp plus margin-trim. In total they ranked twenty proposals and explain their reasoning for each, while emphasizing these personal rankings do not predict how they will vote as Igalia's representative to Interop. They encourage readers to rank and share their own favorite proposals.

In situ Syntax Highlighting in macOS Applications Like Keynote

AI 摘要The author shares a macOS workflow for syntax-highlighting code blocks in place within Keynote (and other apps), built from the highlight command-line tool, a custom shell script, and an Automator Quick Action that adds an entry to the Services submenu of the right-click menu. The setup preserves the original font face and size, though line spacing is reset to 1.0 due to a limitation in highlight, and support for other languages can be added by duplicating the workflow and changing the syntax variable. Tested on macOS Sequoia, the approach has caveats such as failing on text with mixed fonts or sizes and performing no validation that the selected text matches the configured language.

Eighteen

AI 摘要The author reflects on what would have been his daughter Rebecca's eighteenth birthday, twelve years after her death, recalling her funeral and imagining the adulthood she never reached, including a high school graduation she likely would have had. He considers this transition from her 'phantom childhood' to 'phantom adulthood' as a possible turning point for the family, who have traditionally visited her grave together each year and are beginning to discuss loosening that ritual. This year, the family visited on the day itself, where a cellophane spinner cast glowing purple shapes—including a butterfly—across her name, a sight the Rebecca they knew would have loved.

Accessible (I Think) Split-Cell Table Headers

AI 摘要The author describes an attempt to build an accessible split-diagonal table header cell, inspired by Apollo 16 documentation, using rowspan on header cells (to satisfy WCAG 1.3.3), CSS positioning, and a gradient to draw the diagonal. He shares layout caveats, including a Safari bug with relative positioning on thead that required a workaround, and notes basic testing with accessibility experts found no major issues. He ultimately asks assistive technology users to confirm whether the solution actually works well for them.

Canvas-ing the Web

AI 摘要The author describes using Chrome's new flag-gated HTML-in-canvas API to add a one-click 'Download banner image' button to a browser-based tool built at Igalia for generating social media banners and thumbnails. They recount overcoming technical snags, including avoiding infinite recursion when inserting a custom element into a canvas (solved with Element.moveBefore() and connectedMoveCallback()) and dynamically resizing the canvas to fit its content. They conclude that while HTML-in-canvas excels for static screenshot-style use cases like theirs, the inherent mismatch between fluid DOM layout and fixed canvas dimensions will likely limit its broader adoption on the web.