www.ppvke.com/Answer/?/question/151 效果页面
1.下载SyntaxHihglighter源码存放到跟目录
2. 打开app\question\main.php
3. 查找$question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($question_info['question_detail'])));
在这行代码下面 新增
$question_info['question_detail'] = FORMAT::code_decode($question_info['question_detail']);
4.system\class\cls_format.inc.php 任意位置 新增代码如下
//代码反转
public static function code_decode($str){
if($str){
$str = str_replace("<pre", '<pre', $str);
$str = str_replace("<\/pre>", '</pre>', $str);
$str = str_replace(""", '"', $str);
}
return $str;
}
把php部分代码替换成这个.之前的会有问题
JS代码.可直接找我们网站上面找到JS 右键另存为.
之前写的第一版有些BUG.修复了一些.现在可以稳定使用
以上 PHP 部分代码就已实现完成.
下面是HTML代码方面修改
<pre class="brush: html">views\default\question\index.tpl.htm 加入
<script type="text/javascript" src="syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushDelphi.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushDiff.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushGroovy.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushPython.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushScala.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="
http://www.ppvke.com/Answer/sy ... ot%3B/>
<link type="text/css" rel="stylesheet" href="
http://www.ppvke.com/Answer/sy ... ot%3B/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'syntaxhighlighter/scripts/clipboard.swf';
SyntaxHighlighter.config.bloggerMode = true ;
SyntaxHighlighter.config.stripBrs = true ;
SyntaxHighlighter.all();
</script></pre>
以上HTML 就修改完了.
JS部分请直接覆盖static\js\editor\Markdown.Converter.js
代码高亮.RAR包. 请勿直接覆盖你的程序. 否则出现后果 概不负责
可以查看我修改过的东西 HTML 和 php 代码请按上面操作
阅读全文
收起全文