Add line numbers to code blocks on Developer Forum

Show line numbers here:

Without numbers, it is difficult to ask for clarification without quoting the code in question out of context, which then requires every subsequent reader to try and correlate what is being referred to. Additionally, the lack of line numbers tempts people to post screenshots instead, which are problematic for accessibility and make manipulation impossible.

12 Likes

It looks like the author of highlight.js (what is used on Discourse forums for code highlighting) is very opiniated against line numbers: Line numbers — highlight.js 11.9.0 documentation

That being said, someone did some work on a CSS component to add line numbers to Discourse: Is it possible to show line numbers in code block? - #5 by Arjan - Support - Discourse Meta

We can look into adding that if this feature request gets more support.

1 Like

Library maintainers’ opinions don’t count, especially if they are hanging-indented. Otherwise, the typical code posted to this site is already way too big for the column size of posts, so losing 1/8" of space on the left shouldn’t be too serious. Additionally, it could be integrated with the quoting system so that quotes maintain the line numbers of what they are quoting, although that’s way more involved.

3 Likes

Yep, just explaining why it is not on the forum today and for context for other readers or any of my colleagues reading this in the future. :smile:

2 Likes