18 12
发新话题
打印

ZBlog 1.7 代码高亮显示插件

为什么我用不好呢,<br/> 在textarea 里面显示不是换行而是原字符,哪位大哥能给个正常使用的方法

TOP

己所不欲 勿施于人
Http://www.wxbinfo.cn/

TOP

引用:
原帖由 scottliang 于 2007-9-25 12:12 发表
为什么我用不好呢, 在textarea 里面显示不是换行而是原字符,哪位大哥能给个正常使用的方法
想回车 就直接回车好了. 不用BR
欢迎来踩  pencat's blog

http://www.bigcomic.com/blog

TOP

标记语言写html就行 谢谢

TOP

好像很多人还不明白,我也摸索了很多时间。
z-blog不能用SyntaxHighlighter最大的问题就是FCKeditor与UBBeditor都不生成vbcrlf(回车符)
而SyntaxHighlighter以vbcrlf(回车符)作为换行代码换行的依据
感谢搂主提供代码将<br/>转换为vbcrlf(回车符)

我做了点改进:

我觉得更好的办法是把<br />(FCKeditor中默认的回车)转换为vbcrlf(回车符)并在<pre>中搜索替换
因为 textarea 在 FCKeditor 中无法编辑 (这样就不能利用FCKeditor的强大功能了,比如按tab可以生成制表符)
这样也不会有一大堆烦人的<br />在代码中穿插(FCKeditor所见即所得编辑界面中)
这样用户就可以在FCKeditor中插入<pre></pre>在其中加入代码并可以直接按回车键用FCKeditor自动生成<br />

FUNCTION\c_function.asp
296行源基础上修改后如下:
复制内容到剪贴板
代码:
                '## Hack
                Dim PosX,PosY,TempSource,TempSource1,TempSource2
                TempSource = LCase(source)
                  PosY = 1
                Do
                        PosX = Instr(PosY,TempSource,"<pre")               
                        If PosX > 0 Then       
                                PosY = Instr(PosX,TempSource,"</pre>")
                                If PosY  < PosX then
                                   Exit do
                                End If
                                TempSource1 = Mid(source,PosX,PosY-PosX)               
                                TempSource2 = Replace(TempSource1,"
",vbcrlf)
                                TempSource2 = Replace(TempSource2,"’","'")
                                source = Replace(source,TempSource1,TempSource2)
                        Else
                                Exit Do
                        End If                       
                Loop
                '## Over
还可以自己编辑FCKeditor的cssStyle列表
方法请看 http://wiki.fckeditor.net/Develo ... onfiguration/Styles

\ADMIN\FCKeditor\fckstyles.xml
可以参考我的:
复制内容到剪贴板
代码:
        <!-- for code highlight -->
<Style name="CodeJavascript" element="pre">
        <Attribute name="name" value="code" />
        <Attribute name="language" value="javascript" />
</Style>
<Style name="CodeVb" element="pre">
        <Attribute name="name" value="code" />
        <Attribute name="language" value="vb" />
</Style>
<Style name="CodeC#" element="pre">
        <Attribute name="name" value="code" />
        <Attribute name="language" value="C#" />
</Style>
<Style name="CodeCSS" element="pre">
        <Attribute name="name" value="code" />
        <Attribute name="language" value="css" />
</Style>
<Style name="CodeSQL" element="pre">
        <Attribute name="name" value="code" />
        <Attribute name="language" value="sql" />
</Style>
<Style name="CodeXML" element="pre">
        <Attribute name="name" value="code" />
        <Attribute name="language" value="xml" />
</Style>
<!-- end for code highlight -->
然后在\ADMIN\FCKeditor\editor\css\fck_editorarea.css
把原先的.code改为
复制内容到剪贴板
代码:
pre
{
        border: #8b4513 1px solid;
        padding-right: 5px;
        padding-left: 5px;
        color: #000066;
        font-family: 'Courier New' , Monospace;
        background-color: #ff9933;
}
这样在编辑过程中可以有所区别于其他字符

[ 本帖最后由 emj365 于 2007-10-11 06:12 编辑 ]

TOP

看不懂.........
星空NET--欢迎大家来交换友情链接,多多交流!

TOP

 18 12
发新话题