Add starting line to code tag? (JavaRanch forum at Coderanch) (original) (raw)
I had a bit of a play around with this but unfortunately without success. It appears that the Ranch forum uses an old version of Alex Gorbatchev's SyntaxHighlighter, version 1.5.1 for which the documentation lives on this old Google Code page.
The [ code ] tags are BB Code which are translated into HTML when you submit your post. So the following BB Code snip:
[ code=java]
System.out.println("Hello world!");
[ /code]
Translates to HTML:
And gives you the output:
Now, according to the SyntaxHighlighter Wiki on configuration options we can add extra configs to the element class as colon separated items. For example if you wanted to remove the "gutter" (line numbers) and the "controls" you'd need the HTML:
Which if I translate that back to BBCode would be:
[ code=java:nogutter:nocontrols]
System.out.println("Hello world!");
[ /code]
Output:
At this point I'm feeling confident until I notice that the config item for defining the starting line number is "firstline[x]". So to start a Java snip on line 5 you'd need [ code=java:firstline[5]] which doesn't work because the BB Code closes the code tag on the first closing square bracket. So trying:
[ code=java:firstline[5]]
System.out.println("Hello world!");
[ /code]
gives:
Bummer.
I though that you would be able to just use the plain HTML and bypass the BB Code altogether by unchecking the "Disable HTML in this message" option in the post editor. But that didn't work either.
For now I'm out of ideas....