Forum: line numbers on code

On the old forum, code blocks had line numbers – I believe this was done through the Vanilla forum’s SyntaxHighlighter plugin. They helped discussion because commenters could refer to specific lines.

In order for the new Processing forum to add line numbers:

Discourse does not come with code line numbers out of the box, and there is no plan to add them.

  1. This Discourse forum uses highlight.js for syntax highlighting. Highlighted code appears in forum posts wrapped like this:

    <div class="cooked">
        <pre>
            <code class="hljs cs">

  2. Somebody developed a highlightjs line numbering plugin.

  3. Somebody else has tried to use that plugin with Discourse to add line numebrs:

This looks like it might be the way to go if we were trying to solve the same problem.


Notes:

There are related discussions of line numbering on meta.discourse:

10 Likes

This needs more likes

1 Like