Skip to content
Discussion options

You must be logged in to vote

data-gutter isn't part of the exported HTML — it's added at runtime by the code-highlighting plugin, and the line-number column itself is pure CSS. That's why copying the static "Convert to HTML" output doesn't carry it.

In the source (@lexical/code-prism, CodeHighlighterPrism.ts), updateCodeGutter() builds the line-number string and does codeElement.setAttribute('data-gutter', gutter) ("1\n2\n3…"), run from a mutation listener registered by registerCodeHighlighting(editor). The Playground theme then draws it straight from the attribute:

.PlaygroundEditorTheme__code:before {
  content: attr(data-gutter);
  position: sticky; left: 0; float: left;
}

So, to get the gutter in your editor (not…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@etrepum
Comment options

etrepum Jul 15, 2026
Collaborator

Answer selected by hadikman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants