Skip to content

feat(syntax-highlighter): add CSS line numbers via data-linenumbers#36

Open
sushruth wants to merge 5 commits into
mainfrom
claude/add-css-line-numbers-CTSqG
Open

feat(syntax-highlighter): add CSS line numbers via data-linenumbers#36
sushruth wants to merge 5 commits into
mainfrom
claude/add-css-line-numbers-CTSqG

Conversation

@sushruth

@sushruth sushruth commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Line count is computed as a by-product of the existing tokenizer pass
in highlightPre (no second traversal). The count is written as the
data-linenumbers attribute value; CSS ::before { content: attr(...) }
renders the number column with zero new DOM nodes injected into code.

Blocks with data-linenumbers scroll horizontally rather than wrap, so
line numbers stay aligned against long lines.

https://claude.ai/code/session_01BEjyQ3NJxxQqBqQzdWqtKY

claude added 5 commits April 4, 2026 02:00
Line count is computed as a by-product of the existing tokenizer pass
in highlightPre (no second traversal). The count is written as the
data-linenumbers attribute value; CSS ::before { content: attr(...) }
renders the number column with zero new DOM nodes injected into code.

Blocks with data-linenumbers scroll horizontally rather than wrap, so
line numbers stay aligned against long lines.

https://claude.ai/code/session_01BEjyQ3NJxxQqBqQzdWqtKY
Was inlined unnecessarily to hit a hard line limit. The limit is a
guideline; 181 lines is fine.

https://claude.ai/code/session_01BEjyQ3NJxxQqBqQzdWqtKY
white-space, overflow-x, and min-width are correctness constraints for
line number alignment, not style preferences. !important prevents
accidental CSS overrides from silently breaking number sync.

https://claude.ai/code/session_01BEjyQ3NJxxQqBqQzdWqtKY
- Bump version 0.2.3 → 0.3.0
- Add CHANGELOG.md
- Add data-linenumbers to file/source code blocks in docs fragments
  (architecture, platform-eng, product-eng, tutorials); shell commands
  and short concept snippets left unchanged

To publish: cd toolkit/syntax-highlighter && bun run publish

https://claude.ai/code/session_01BEjyQ3NJxxQqBqQzdWqtKY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants