Question

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?

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top