SyntaxHighlighter 不格式化 xml 文本
参考文件:
<script src="../../Content/dp.SyntaxHighlighter/Scripts/shCore.js" type="text/javascript"></script>
<script src="../../Content/dp.SyntaxHighlighter/Scripts/shBrushXml.js" type="text/javascript"></script>
<link href="../../Content/dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css" rel="stylesheet" type="text/css" />
html代码:
<pre class="brush:xml;">
@Html.Encode("<?xml version='1.0'?><response value='ok' xml:lang='en'> <text>Ok</text> <comment html_allowed='true'/> <ns1:description> descriptin. </ns1:description> <a></a> <a/></response>")
</pre>
JavaScript代码:
<script type="text/javascript">
SyntaxHighlighter.all()
</script
这里有参考教程
Reference files:
<script src="../../Content/dp.SyntaxHighlighter/Scripts/shCore.js" type="text/javascript"></script>
<script src="../../Content/dp.SyntaxHighlighter/Scripts/shBrushXml.js" type="text/javascript"></script>
<link href="../../Content/dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css" rel="stylesheet" type="text/css" />
html Code:
<pre class="brush:xml;">
@Html.Encode("<?xml version='1.0'?><response value='ok' xml:lang='en'> <text>Ok</text> <comment html_allowed='true'/> <ns1:description> descriptin. </ns1:description> <a></a> <a/></response>")
</pre>
JavaScript Code:
<script type="text/javascript">
SyntaxHighlighter.all()
</script
here is got reference tutorial
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看源代码,您会发现您对 XML 进行了两次转义,因为
@
已经对文本进行了编码,而@Html.Encode(..)
再做一次。因此,您没有获得 SyntaxHighlighter 理解为代码的正确输出。只需使用此示例进行测试,一切都会正常工作:
If you take a look at the source you'll notice that you're excaping the XML two times since
@
already encodes the text while@Html.Encode(..)
does it again. Therefore you're not getting correct output that SyntaxHighlighter undestand as code.Just test using this example and everything will work fine: