Remove line numbers from SyntaxHighlighter
Asked Answered
T

4

7

Is there any way to remove the line numbers of SyntaxHighlighter?

Thanks!

Thurnau answered 28/3, 2009 at 9:9 Comment(0)
T
19

You can set the SyntaxHighliter's gutter configuration to false. This will remove the line number from your code.

<pre class="brush: java; gutter: false;"></pre>
Thacher answered 21/5, 2009 at 0:4 Comment(2)
In fact, one can do this "inline", per code snippet: <script class="brush: python;gutter: false" type="syntaxhighlighter"> <![CDATA[ <code> range(1027) </code> ]]> </script>Jeanette
This removes not only the line numbers, but the gutter, which is useful for distinguishing the code from the surrounding text.Spence
A
1

Hit the "view plain" link?

Taking a look at the SyntaxHighlighter demo you will see it has buttons in the top right corner which you can click to either copy the code to your clipboard, see the actual source code (removing markup) and or print it.

Are you asking us how to remove the actual feature that adds the line numbers while still keeping the rest of the functionality in place? Are you asking us to do this for you?

In response to comment:

If you want to keep the functionality in place, and just remove the line numbers you will need to download a copy of the javascript file for yourself and remove the features you don't want. the SyntaxHighlighter download page allows you to download your very own version of the highlighter, it also tells you that is is licensed under the LGPL 3, which means you have to follow those rules when you make and use your modifications.

If you want, you may come back and ask individual Javascript questions, if you get stuck in a particular spot, but we are not TopCoder nor will we re-write code for you.

Alcina answered 28/3, 2009 at 9:11 Comment(2)
no, I'm not. I'm just asking if anybody knows how to make it render without the line numbers. If there is no such option, I'll just modify it myself. ThanksThurnau
I came here and I would like to see someone removing the actual feature that adds the line numbers while keeping the rest of the functionality in place. I have a lot of one-liners where I would like to have a control to switch off line numbering for some (not all) of my code-blocks.Isometry
P
0

If you don't want to edit your existing markup, you can turn it off globally by editing the shCore.js file:

var sh = {
defaults : {

    ...
    ...
    ...

    /** Enables or disables gutter. */
    'gutter' : false,

    ...
    ...
    ...

},

...
...
...
}
Pindling answered 21/9, 2014 at 8:24 Comment(0)
S
0

You can set the default of 'gutter' => 0 in SyntaxHighlighter Evolved version 3.2.1 by editing the file syntaxhighlighter.php. Look for this in the file:

// Create array of default settings (you can use the filter to modify these)
        $this->defaultsettings = (array) apply_filters( 
            'syntaxhighlighter_defaultsettings', array(
            'theme'          => 'default',
            'loadallbrushes' => 0,
            'shversion'      => 3,
            'title'          => '',
            'autolinks'      => 1,
            'classname'      => '',
            'collapse'       => 0,
            'firstline'      => 1,
            'gutter'         => 0,
            'htmlscript'     => 0,
            'light'          => 0,
            'padlinenumbers' => 'false',
            'smarttabs'      => 1,
            'tabsize'        => 4,
            'toolbar'        => 0,
            'wraplines'      => 1, // 2.x only
        ) );
Sled answered 24/6, 2017 at 3:48 Comment(2)
Can you be more explicit?Sled
I am saying that SO have a very useful tool for Question and answer insert, so you can use it and made your answer more mining full and more accurate looking.Apivorous

© 2022 - 2024 — McMap. All rights reserved.