超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測評推薦
專注分享VPS主機優(yōu)惠信息
衡天云優(yōu)惠活動
熱網(wǎng)互聯(lián)2026年促銷活動
hostkvm優(yōu)惠促銷活動
zji優(yōu)惠促銷活動
QQGNET優(yōu)惠促銷活動
QQGNET優(yōu)惠促銷活動

如何在DedeCms 5.7中實現(xiàn)代碼高亮顯示

主機參考:VPS測評參考推薦/專注分享VPS服務(wù)器優(yōu)惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務(wù),查看詳情!
我們發(fā)布的部分優(yōu)惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關(guān)文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

如何在DedeCms 5.7中實現(xiàn)代碼高亮顯示

如何突出顯示dedecms 5.7代碼?

無論如何構(gòu)建博客網(wǎng)站或CMS網(wǎng)站,其中許多網(wǎng)站都需要代碼突出顯示。Dreaming CMS是中國優(yōu)秀的CMS建站系統(tǒng)之一,不像Wordpress有很多插件。我用的是最新的dedeCMS 5.7,在網(wǎng)上搜了很久的資料。他們中的大多數(shù)人寫了關(guān)于CKEditor和SyntaxHighlighter集成的文章,但DEECMS集成了CKEDIT,并且通常只關(guān)注ckeditor的config.js

推薦學(xué)習(xí):夢想編織cms

所以我只能自己琢磨修改。現(xiàn)在我將方法寫出來供站長朋友們參考:

首先,去SyntaxHighlighter的官方網(wǎng)站下載。網(wǎng)站地址是http://alexgorbatchev.com/SyntaxHighlighter/download/.,建議下載2.1版本。3.0版本好像不支持自動換行,這里用的是2.1.382版本。將下載的文件解壓到syntaxHighlight文件夾中,并刪除里面無用的文件,只保留腳本和樣式文件夾。

其次,創(chuàng)建一個新的dialogs文件夾,并在其中創(chuàng)建一個名為Syntaxihighlight.js的新文件。由于代碼量很大,所以不適合發(fā)布。請直接下載Syntaxihighlight.js。

如果您想修改代碼區(qū)的樣式,請在以下代碼處進行修改。

標(biāo)簽中的樣式。代碼如下:

onOk:function(){ var I = this . get parent editor();var h = I。get selection();var g = h . getstartelement();var l = g &amp。& ampg . getascendant(& quot;pre & quot,真);var j = f();this . commit content(j);var k = e(j);var m = CKEDITOR.dom.element。createfrohtml(& amp;#39;& lt表格樣式= & quot邊框:1px solid # EAED9C寬度:660px"& gt& lttr & gt& lttd & gt& ltpre class = & quot& amp#39;+k+& amp;#39;"& gt& amp#39;+c(j . code)+& quot;");if(l){ m . insert before(l);l . remove()} else { I。insert element(m)} },3。然后創(chuàng)建一個新的圖像文件夾來存儲圖片文件syntaxhighlight.gif,該文件顯示在編輯器工具欄上,可以使用16*16像素的圖片。

第四,創(chuàng)建一個新的lang文件夾,這是一個語言包。其中有兩個文件,一個是中文cn.js,另一個是英文en.js .代碼內(nèi)容如下:

En.js代碼如下:

代碼如下:

CK editor . plugins . set lang(& amp;#39;syntaxhighlight & amp#39;,& amp#39;en & amp#39;,{ syntaxhighlight: { title:#39;添加或更新代碼片段& amp#39;,source tab:& amp;#39;源代碼& amp#39;,lang LBL:& amp;#39;選擇語言。#39;,高級標(biāo)簽:& amp#39;高級& amp#39;,隱藏陰溝:& amp#39;隱藏水槽和。#39;,hidegutterbl:& amp;#39;隱藏水槽和。行號。& amp#39;,隱藏控件:& amp#39;隱藏控件。#39;,hideControlsLbl:& amp;#39;在代碼塊頂部隱藏代碼控件。& amp#39;,崩潰:& amp#39;崩潰&amp。#39;,collapse LBL:& amp;#39;默認(rèn)情況下折疊代碼塊。(需要打開控件)& amp#39;,顯示列:& amp#39;顯示列& amp#39;,showColumnsLbl:& amp;#39;在第一行顯示行列。& amp#39;換行:& amp#39;禁用換行。#39;,line wrap LBL:& amp;#39;關(guān)閉換行。& amp#39;,行數(shù):& amp#39;默認(rèn)行數(shù)&amp。#39;,高亮顯示:& amp#39;高光線條&amp。#39;,highlight LBL:& amp;#39;輸入要突出顯示的逗號分隔的行,例如& ltem & gt3,10,15 & lt/em & gt;。& amp#39;} });cn.js的代碼如下:

代碼如下:

CK editor . plugins . set lang(& amp;#39;syntaxhighlight & amp#39;,& amp#39;cn & amp#39;,{ syntaxhighlight: { title:#39;添加或更新代碼&;#39;,source tab:& amp;#39;code &;#39;,lang LBL:& amp;#39;選擇一種語言&;#39;,高級標(biāo)簽:& amp#39;高級&;#39;,隱藏溝:& amp#39;隱藏分界線&;#39;,hideGutterLbl:& amp;#39;隱藏分割線和行號&;#39;,隱藏控件:& amp#39;隱藏工具欄&;#39;,hideControlsLbl:& amp;#39;隱藏浮動工具欄&;#39;,崩潰:& amp#39;代碼折疊&;#39;,collapse LBL:& amp;#39;默認(rèn)情況下折疊代碼塊(需要啟用工具欄)&;#39;換行:& amp#39;自動換行&;#39;,line wrap LBL:& amp;#39;關(guān)閉自動換行&;#39;,自動鏈接:#39;自動鏈接&;#39;,autoLinksLbl:& amp;#39;不自動轉(zhuǎn)換超鏈接&;#39;,行數(shù):& amp#39;起始行號&;#39;,高亮顯示:& amp#39;突出顯示行號&;#39;,highlight LBL:& amp;#39;輸入逗號分隔的行號,例如

代碼如下:

CK editor . plugins . add(& quot;語法高亮顯示& quot,{要求:

將syntaxhighlight文件夾上傳到/include/ckeditor/plugins/文件夾,打開背景,添加一篇文章并嘗試查看編輯器最后一行是否有如圖所示的按鈕:

5f49ce6b8a4413d3420420d886faaf0.png

點擊按鈕彈出如下圖所示的對話框輸入代碼,可以切換到高級選項對代碼進行一些高亮顯示的配置:

4dbff50ca62f9807db4a2d542ac15c3.png

八、但這些還不夠,還要在文章模板文件/templates/default/article _ article.htm文件中引入高亮顯示的畫筆JS文件和CSS文件,因為有必要引入大量的JS,所以建議把導(dǎo)入的代碼放進去。

標(biāo)簽,等待加載并顯示上一頁。

代碼如下:

& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shcore . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush Java . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrushjscript . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush PHP . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush Scala . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush SQL . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/cke editor/plugins/syntax highlight/scripts/shbrush VB . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush XML . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush bash . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrushcpp . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/cke editor/plugins/syntax highlight/scripts/shbrushcsharp . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/cke editor/plugins/syntax highlight/scripts/shbrushcss . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/cke editor/plugins/syntax highlight/scripts/shbrush Delphi . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush diff . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/cke editor/plugins/syntax highlight/scripts/shbrushgroovy . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush plain . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/CK editor/plugins/syntax highlight/scripts/shbrush python . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot/include/cke editor/plugins/syntax highlight/scripts/shbrush ruby . js & quot;& gt& lt/script & gt;& lt鏈接類型= & quottext/CSS & quot;rel = & quot樣式表& quothref = & quot/include/CK editor/plugins/syntax highlight/styles/sh core . CSS & quot;/& gt;& lt鏈接類型= & quottext/CSS & quot;rel = & quot樣式表& quothref = & quot/include/CK editor/plugins/syntax highlight/styles/shthemedefault . CSS & quot;/& gt;& lt腳本類型= & quot文本/JavaScript & quot;& gtsyntax highlight er . config . clipboard swf = & amp;#39;/include/cke editor/plugins/syntax highlight/scripts/clipboard . swf & amp;#39;;syntax highlight er . all();& lt/script & gt;

最終發(fā)布和生成的文章頁面效果圖如下:

48df14a73876819741cda56b70e62cf.png

當(dāng)然,集成也有一些缺點,即html頁面中可能會引入大量JS文件,加載速度可能會很慢,并且可擴展性不強。我也會不定期優(yōu)化插件,希望各位網(wǎng)友多多指教。

這幾篇文章你可能也喜歡:

本文由主機參考刊發(fā),轉(zhuǎn)載請注明:如何在DedeCms 5.7中實現(xiàn)代碼高亮顯示 http://m.k2270.com/109941.html

【騰訊云】領(lǐng)8888元采購禮包,搶爆款云服務(wù)器 每月 9元起,個人開發(fā)者加享折上折!
打賞
轉(zhuǎn)載請注明原文鏈接:主機參考 » 如何在DedeCms 5.7中實現(xiàn)代碼高亮顯示
主機參考僅做資料收集,不對商家任何信息及交易做信用擔(dān)保,購買前請注意風(fēng)險,有交易糾紛請自行解決!請查閱:特別聲明

評論 搶沙發(fā)

評論前必須登錄!