文章写作:如何更改代码块中的背景颜色 [英] Article writing: How to change the background color in code block
问题描述
我想通过更改颜色或背景颜色(最好是背景颜色)来突出显示单个代码块的某些部分。
我尝试过使用span,例如
I would like to highlight some parts of a single code block by changing either the color or the background color, preferably background color.
I've tried using span, for example
<span style="background-color:lightgreen">Some code</span>
为了生产
一些代码
但是,似乎这在代码块中不起作用。例如
尝试{
< span style =background-color:lightgreen>做点什么< / span> ;
}
产生以下内容(仍显示标签且无实际效果)
in order to produce
Some code
However, it seems that this doesn't work inside code blocks. For example
try {
<span style="background-color:lightgreen">do something</span>
}
produces the following (still the tag is shown and no actual effect)
try {
<span style="background-color:lightgreen">do something</span>
}
我有什么想法可以使用着色?
我已经尝试过使用粗体和放大器斜体,但它们实际上并没有在代码块中绘制任何吸引力。
Any ideas how I could use coloring?
I already tried using bold & italic but they don't actually draw any attraction inside a code block.
推荐答案
希望黄色适合。
参见http://www.codeproject.com/Info/FAQ.aspx [ ^ ]>章节突出显示代码。
Hope yellow can fit.
See http://www.codeproject.com/Info/FAQ.aspx[^] > chapter Highlighting code.
<pre lang="cs">// This is an important variable name
int <span class="highlight">myVar</span> = 0;
</pre>
看起来像
Will look like
// This is an important variable name
int <span class="highlight" >myVar</span> = 0;
但是可能会因为< /之后的文字而被窃听span>
没有出现或QA中不支持。
But it may be bugged since the text after </span>
do not appear or it is not supported in QA.
Mika,我认为这不受支持。您是否在CodeProject中看到过这个?
此外,我建议您在文章帮助论坛 [ ^ ]。
Mika, I think this is not supported. Have you seen this anywhere in CodeProject?
Also, I would suggest you to post this in Article Help Forum[^].
这篇关于文章写作:如何更改代码块中的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!