shikijs / shiki-magic-move

Smoothly animated code blocks with Shiki
https://shiki-magic-move.netlify.app/
MIT License
1.11k stars 32 forks source link

Line numbers #10

Closed mattcroat closed 2 months ago

mattcroat commented 2 months ago

Is there a simpler way of adding line numbers to code blocks besides using CSS counters?

It kind of works but it's not perfect.

https://github.com/shikijs/shiki-magic-move/assets/38083522/1a93d04d-893e-434e-bf3a-7211de5f8b99

pre {
  counter-reset: count 1;
}

pre br + span {
  position: relative;
  font-family: monospace;
  counter-increment: count;
}

pre span:nth-of-type(1)::before,
pre br + span::before {
  content: counter(count);
  position: absolute;
  top: 0px;
  left: -60px;
  color: #fff;
  opacity: 0.2;
}