Skip to content

Conversation

@NotTheDr01ds
Copy link
Contributor

Fixes #1573 on my local system (as well as my test VuePress repo). Had to look at the VuePress Ecosystem doc repo to see what they were doing. Turns out we need both PrismJS line-numbering config in addition to Shiki config.

I've set both to start numbering code-blocks when they have 10 or more lines. This seems to work fairly well.

@fdncred
Copy link
Contributor

fdncred commented Nov 5, 2024

I'm glad you figured out what was going on but I'm not sure why we only allow line numbers when there are 10 or more lines? Why not just have them enabled all the time?

@NotTheDr01ds
Copy link
Contributor Author

NotTheDr01ds commented Nov 5, 2024

I'm not sure why we only allow line numbers when there are 10 or more lines? Why not just have them enabled all the time?

It's pretty ugly on shorter code-blocks, especially when there are a lot of code-blocks in the "vertical scroll" at once. For example:

But this looks much more natural without numbering:

I think @hustcer agrees, as he's tried to turn it off in the past (most recently in #1577 and 7679879) unsuccessfully (at least ever since moving to Shiki).

I set it to 10 because it does come in useful (and looks okay) on longer blocks, but I wouldn't recommend going lower than 8 for that value. The lower you go, the more chance of having multiple code-blocks with numbers that break up the flow of the reading.

Side note: I also picked 10 because this is the value that the VuePress team uses, and after trying it out, I thought it worked well.

@fdncred
Copy link
Contributor

fdncred commented Nov 5, 2024

I like it the "ugly" way.

@NotTheDr01ds
Copy link
Contributor Author

I like it the "ugly" way.

Even on 1 and 2-liners?

@fdncred
Copy link
Contributor

fdncred commented Nov 5, 2024

yup, but that's me. i'm fine with doing it your way. i just like always showing line numbers. it reminds me of my editor. it always shows line numbers no matter how many lines i have.

@NotTheDr01ds
Copy link
Contributor Author

it reminds me of my editor

Ironically, maybe that's part of my problem with the line numbers. Nushell itself doesn't have line-numbers, and many code-blocks are about typing commands into the shell rather than an editor.

It's also kind of odd seeing line-numbers next to the table-borders.

Note that we can still "force" line numbering on for any block we want to using:

```nu:line-numbers
# => code block
```

And I'll probably do that for some of the shorter ones when we want to point out something on a particular line. Conversely, we can also turn them off for some when they really, really aren't necessary.

i'm fine with doing it your way.

I did try bumping the value down to 5 to see if it was a good compromise, but I still think 10 is probably the sweet-spot (might could get away with 8). Like I said, once we turn them off (if you're okay with that), I'll start "overriding" a few of them manually.

@fdncred fdncred merged commit 2518f7b into nushell:main Nov 6, 2024
2 checks passed
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.

Line numbers in code blocks

2 participants