问题描述
我正在使用中的js SyntaxHighlighter 3.0.83 / p>
我一直在谷歌搜索整个世界,但似乎无法真正找到如何启用换行符。 Instad我得到一个水平滚动条,这有时很好但不在我的场景中。
例如
有谁知道这方面的方式?
我实际上并没有使用SyntaxHighlight,但似乎可以附加一个空格:pre-wrap
CSS样式到< pre>
或< script>
标签,SyntaxHighlight使用。
HTML(使用< pre>
):
< pre class =brush:jsclass =syntaxhighlight>
/ **
* SyntaxHighlighter
* /
function foo()
{
if(counter< = 10)
return;
//它有效!
}
< / pre>
HTML(使用< script>
) :
< script type =syntaxhighlighterclass =syntaxhighlight brush:js><![CDATA [
/ **
* SyntaxHighlighter
* /
函数foo()
{
if(counter< = 10)
return;
//它有效!
}
]]>< / script>
CSS:
.syntaxhighlight {
white-space:pre-wrap;
}
Im using the js SyntaxHighlighter 3.0.83 from http://alexgorbatchev.com/SyntaxHighlighter/
I've been googling the entire world now it seem but cant really find how to enable line breaks. Instad i get a horizontal scrollbar, which is good sometimes but not in my scenario.
In example
Anyone out there who know the way around this?
I don't actually use SyntaxHighlight, but it seems to be possible to attach an white-space: pre-wrap
CSS style to the <pre>
or <script>
tag that SyntaxHighlight uses.
HTML (using <pre>
):
<pre class="brush: js" class="syntaxhighlight">
/**
* SyntaxHighlighter
*/
function foo()
{
if (counter <= 10)
return;
// it works!
}
</pre>
HTML (using <script>
):
<script type="syntaxhighlighter" class="syntaxhighlight brush: js"><![CDATA[
/**
* SyntaxHighlighter
*/
function foo()
{
if (counter <= 10)
return;
// it works!
}
]]></script>
CSS:
.syntaxhighlight {
white-space: pre-wrap;
}
这篇关于js SyntaxHighlighter中的自动换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!