主题: 我想将kindeditor与syntaxhighlighter结合起来,按照网上的做法一直不成功
作者: linytSysu, 发布日期: 2014-10-01 20:04:46, 浏览数: 1956

    按照这个上面来进行,http://w3note.com/web/3.html,先改了code.js,然后加载了syntax的相关文件,但是一直无法将代码高亮。

   请问有谁做过这个工作的指点一下。

以下是我的代码:


<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Default Examples</title>
		<style>
			form {
				margin: 0;
			}
			textarea {
				display: block;
			}
		</style>
		<link rel="stylesheet" href="kindeditor/themes/default/default.css" />
		<script charset="utf-8" src="kindeditor/kindeditor-min.js"></script>
		<script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>

		<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/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="syntaxhighlighter/styles/shCore.css">
        <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemeDefault.css">
        <script>
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
					allowFileManager : true,
				});
			});
		</script>
	</head>
	<body>
		<h3>默认模式</h3>
		<form>
			<textarea id="editor_id" name="content" style="width:800px;height:400px;visibility:hidden;">KindEditor</textarea>
		</form>
		<div id="show">
        </div>
        <script type="text/javascript">
            function addText() {
                editor.sync();
                var text = document.getElementById("editor_id").value;
                show.innerHTML=text;
            }
        </script>
        <button type="submit" class="clear" onclick="addText()">click me</button>
    </div>
	</body>
    <script>SyntaxHighlighter.all();</script>
</html>

帮帮新人吧。


作者: 小浪子, 发布日期: 2014-10-02 12:07:53
<!doctype html>
<html>
        <head>
                <meta charset="utf-8" />
                <title>Default Examples</title>
                <style>
                        form {
                                margin: 0;
                        }
                        textarea {
                                display: block;
                        }
                </style>
                <link rel="stylesheet" href="kindeditor/themes/default/default.css" />
                <script charset="utf-8" src="kindeditor/kindeditor-min.js"></script>
                <script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>

                <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/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="syntaxhighlighter/styles/shCore.css">
        <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemeDefault.css">
        <script>
                        var editor;
                        KindEditor.ready(function(K) {
                                editor = K.create('textarea[name="content"]', {
                                        allowFileManager : true,
                                });
                        });
                </script>
        </head>
        <body>
                <h3>默认模式</h3>
                <form>
                        <textarea id="editor_id" name="content" style="width:800px;height:400px;visibility:hidden;">KindEditor</textarea>
                </form>
                <div id="show">
        </div>
        <script type="text/javascript">
            function addText() {
                editor.sync();
                var text = document.getElementById("editor_id").value;
                show.innerHTML=text;
                // 放到这里执行
                SyntaxHighlighter.all();
            }
        </script>
        <button type="submit" class="clear" onclick="addText()">click me</button>
    </div>
        </body>
</html>
回复
作者: linytSysu, 发布日期: 2014-10-04 23:41:33

谢谢你,我按照你的方法又试了一遍,结果还是不行。

不知道是什么原因,你成功了吗?

回复
作者: gooken, 发布日期: 2014-10-07 01:17:42
我也按网上说的弄了,HTML 那段改了是没有用的 。生成的代码始终不会变 。。。哎 希望你找到了原因。。。
回复
作者: 陶子, 发布日期: 2014-10-27 23:31:44

你代码太多了,没法看,给你个教程参考下。


http://tech.shenline.com/cms/phpcms/2013/1118/4.html

回复
发表新帖 发表回复