Reputation: 21
I use pygments to highlight code.
And I want to add some specify style to a part of code in highlight block.
For example, I want to change "private String" color to red.
{% highlight java %}
public class A {
<span color="red">private String</span> xx;
}
{% endhighlight %}
How can I do this?
Upvotes: 2
Views: 327
Reputation: 52809
A Name token is transformed by Pygments to :
<span class="n">Private</span>
<span class="n">String</span>
<span class="n">name</span>
or
<span class="o">(</span>
<span class="n">String</span>
<span class="n">name</span>
<span class="o">){</span>
Styling .n class can be done in your highlight.css (or maybe .scss) with :
.highlight .n{ color: red; }
But you will not target the Private String specific token. If you want to do so, you will have to write you own Pygments lexer
Upvotes: 1