saberland / saber

()==[:::::::::::::> Build static sites in Vue.js, without the hassle
https://saber.egoist.dev
MIT License
2.15k stars 112 forks source link

Feature request: Expose line number index for color highlighting #600

Closed Apostolique closed 4 years ago

Apostolique commented 4 years ago

Feature request

What problem does this feature solve?

It makes it possible to start the lines numbers to something else than 1.

What does the proposed API look like?

Exposed in a similar way to the current line highlighting in the markdown.

How should this be implemented in your opinion?

https://github.com/saberland/saber/blob/ec2cbac5a093edbe7454f14a0cfd1af6276c1ab3/packages/saber/src/markdown/highlight-plugin.js#L66

Are you willing to work on this yourself?

I could if no one else does.

egoist commented 4 years ago

We are using CSS counters in saber-highlight-css:

https://github.com/saberland/saber/blob/ec2cbac5a093edbe7454f14a0cfd1af6276c1ab3/packages/saber-highlight-css/default.css#L74

So probably we should inline that style into this line instead:

https://github.com/saberland/saber/blob/ec2cbac5a093edbe7454f14a0cfd1af6276c1ab3/packages/saber/src/markdown/highlight-plugin.js#L14

Like this:

<span 
  aria-hidden="true" 
  class="saber-highlight-line-numbers" 
  style="counter-reset: linenumber 0">

And make that 0 customizable.