0

Say I've got this source snippet in a trac ticket:

var a = 1;
var b = 2;
alert(b);

In order to have it rendered as source code, I put up the needed {{{ ... }}} block around the statement:

{{{#!js
    var a = 1;
    var b = 2;
    alert(b);
}}}

How do I achieve it that the line var b = 2; is rendered for example in red?

eckes
  • 64,417
  • 29
  • 168
  • 201
  • 1
    With the current trunk, and forthcoming in Trac 1.1.2 (see [#10834](http://trac.edgewall.org/ticket/10834)), you can add line numbers and highlight lines in code blocks. `{{{#!js lineno marks=2` would add highlighting to the second line in your code block (and also add line numbers). – RjOllos Nov 05 '13 at 18:46
  • @RjOllos: great news to hear. Thank you. – eckes Nov 06 '13 at 07:06

1 Answers1

3

Cascading WikiProcessors is not supported for external lexers like for javascript.

Trac's own processors for advanced tables and paragraphs (lend from HTML tag) are the exceptions. So the following works in some way:

{{{#!js
    var a = 1;
}}}
{{{#!div style="color:red"
{{{#!js
    var b = 2;
}}}
}}}
{{{#!js
    alert(b);
}}}

But it's breaking the code into pieces as a side-effect of cascaded div's with default styling (includes margin/padding).

hasienda
  • 2,390
  • 1
  • 13
  • 16