DBS独立服客服务

查看完整版本: ZBlog 1.7 代码高亮显示插件

pencat 2007-8-21 03:56

ZBlog 1.7 代码高亮显示插件

自从换了ZBlog1.7之后代码都不能看了. 把之前的插件做了一下小改动,再发上来.

[b]一[size=1em]、适用版本[/size][/b]
ZBlog 1.7 Laputa Build 70216

[b][size=1em]二、下载[/size][/b]
[url=http://blog.bigcomic.com/post/2007/08/21/HighLighter1.7.html]http://blog.bigcomic.com/post/2007/08/21/HighLighter1.7.html[/url]

[b][size=1em]三、安装[/size][/b]
将压缩包中的文件覆盖到Blog的跟目录即可
[b][size=1em][size=1em][/size][/size][/b]
[b][size=1em][size=1em]四[/size]、使用[/size][/b]
1. 使用代码高亮标签时,需要<textarea></textarea>标签的支持。将代码放入<textarea>之中。
eg. 代码中的红字可以替换成你所需要的语言 [font=Verdana]c#,[font=Verdana]javascript,vb,xml,php,sql,delphi,[font=Verdana]Python[/font][/font][/font]

<textarea name="code" language="[color=#ff0033]vb[/color]">
'/**
' * @param KeepAlive成功
' */
Public Sub OnKeepAliveSucceed(ByVal Index As Long)
    '/** 构造好友状态查看请求包 */
    objPacket(Index).PacketType = QQ_CMD_GET_FRIEND_ONLINE
    '/** 发送好友状态查看请求包 */
    SendData objPacket(Index), Index
    RaiseEvent OnKeepAliveSucceed(Index)
End Sub

</textarea>

[b][size=1em]五、改动的文件[/size][/b]
[font=Verdana][font=Verdana]TEMPLATE\[font=Verdana]default.html
[/font][/font][/font][font=Verdana]TEMPLATE\[font=Verdana][font=Verdana]single.html[/font][/font][/font]
[font=Verdana]TEMPLATE\[font=Verdana][font=Verdana]catalog.html[/font][/font][font=Verdana][font=Verdana]
[font=Verdana][font=Verdana][font=Verdana]FUNCTION\[font=Verdana]c_function.asp[/font][/font][/font][/font][/font][/font][/font]

296行处增加如下代码
'## Hack
Dim PosX, PosY, TempSource, TempSource1, TempSource2
TempSource = LCase(Source)
PosY = 1
Do
        TempSource1 = Mid(Source, PosX, PosY - PosX)
        TempSource2 = Replace(TempSource1, "<br/>", vbCrLf & vbCrLf)
        TempSource2 = Replace(TempSource2, "’", "'")
        Source = Replace(Source, TempSource1, TempSource2)
    Else
        Exit Do
    End If
Loop
'## Over

[b][size=1em]六、声明[/size][/b]
本插件使用第三方提供的JS制作.

[[i] 本帖最后由 pencat 于 2007-9-18 11:39 编辑 [/i]]

Zx.MYS 2007-8-21 16:53

第三方提供的JS制作是指?

pencat 2007-8-21 20:03

SyntaxHighlighter 最新版 1.5.1  compressed

海天飞跃 2007-8-23 20:22

支持,虽然我不是很懂

yangkui 2007-8-26 11:56

不错!这个!!:lol

xsolary 2007-8-26 12:12

如果多支持几种语言可能会更好。。

pencat 2007-8-27 03:52

我有点懒 没把所有支持语言写出来 以下是支持的全部语言

Cpp
CSharp
Css
Delphi
Java
JScript
Php
Python
Ruby
Sql
Vb
Xml

lamyee 2007-8-27 14:50

不错

lenglau 2007-8-27 23:48

有支持asp高亮显示的文件吗,自己按照网上现有的尝试做了几个都不成功- -! 求助~

lenglau 2007-8-27 23:55

去[url]http://code.google.com/p/syntaxhighlighter/wiki/Languages[/url]看了看 原来xml就可以- -!

pencat 2007-8-28 02:42

[quote]原帖由 [i]lenglau[/i] 于 2007-8-27 23:48 发表 [url=http://bbs.rainbowsoft.org/redirect.php?goto=findpost&pid=41720&ptid=16234][img]http://bbs.rainbowsoft.org/images/common/back.gif[/img][/url]
有支持asp高亮显示的文件吗,自己按照网上现有的尝试做了几个都不成功- -! 求助~ [/quote]

标记语言写html就行

kvgnt 2007-9-1 08:39

好东西。谢谢LZ分享。

scottliang 2007-9-25 12:12

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

nethief 2007-9-25 17:40

:lol :victory:

pencat 2007-10-5 14:31

[quote]原帖由 [i]scottliang[/i] 于 2007-9-25 12:12 发表 [url=http://bbs.rainbowsoft.org/redirect.php?goto=findpost&pid=45507&ptid=16234][img]http://bbs.rainbowsoft.org/images/common/back.gif[/img][/url]
为什么我用不好呢, 在textarea 里面显示不是换行而是原字符,哪位大哥能给个正常使用的方法 [/quote]


想回车 就直接回车好了. 不用BR

hanyunfei 2007-10-8 14:37

标记语言写html就行 谢谢

emj365 2007-10-11 06:02

好像很多人还不明白,我也摸索了很多时间。
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行源基础上修改后如下:[code]                '## 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[/code]还可以自己编辑FCKeditor的cssStyle列表
方法请看 [url]http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Styles[/url]

\ADMIN\FCKeditor\fckstyles.xml
可以参考我的:[code]        <!-- 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 -->[/code]然后在\ADMIN\FCKeditor\editor\css\fck_editorarea.css
把原先的.code改为[code]pre
{
        border: #8b4513 1px solid;
        padding-right: 5px;
        padding-left: 5px;
        color: #000066;
        font-family: 'Courier New' , Monospace;
        background-color: #ff9933;
}[/code]这样在编辑过程中可以有所区别于其他字符

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

星空 2007-10-27 18:02

看不懂.........
页: [1]
查看完整版本: ZBlog 1.7 代码高亮显示插件