WordPress作品页代码高亮插件WP-Syntax

原创

WordPress作品页代码高亮插件WP-Syntax

冬镜SEO在此之前从来运用WP-CodeBox代码高亮插件

但运用Windows Live Writer (简称 WLW)颁布含有代码的作品代码城市被转义

须要加入WordPress后盾的Html形式下从新编纂代码

过程冬镜百度探求得悉+要提防转义不妨增添 escaped=”true” 属性

尝试后创造WP-CodeBox插件不扶助 escaped=”true” 属性以是只好另寻其余插件

因为WP-CodeBox运用的是<pre />容器以是也最佳找个同样运用<pre />容器的插件

结果采用了WP-Syntax代码高亮插件

WP-Syntax和 WP-CodeBox都是鉴于GeSHi扶助的谈话的语法运用本领基础一律,最要害的是WP-Syntax 扶助escaped=”true” 属性

WP-Syntax代码抄写方法

<pre lang=”html” line=”1″ escaped=”true” >

//这边增添代码……

</pre>

提醒:

lang=”html”表白代码谈话为html 请按照本人须要窜改

line=”1″ 表白表露行号 不须要去掉即可

escaped=”true” 是为了提防代码转义 不须要去掉即可

提防:

在wordpress后盾运用WP-Syntax等代码高亮插件须要在html形式下增添代码,不要随便切换到可视化形式简单引导代码转义

WP-Syntax 插件扶助的高亮谈话

‘actionscript’ => array(‘as’),

‘ada’ => array(‘a’, ‘ada’, ‘adb’, ‘ads’),

‘apache’ => array(‘conf’),

‘asm’ => array(‘ash’, ‘asm’, ‘inc’),

‘asp’ => array(‘asp’),

‘bash’ => array(‘sh’),

‘bf’ => array(‘bf’),

‘c’ => array(‘c’, ‘h’),

‘c_mac’ => array(‘c’, ‘h’),

‘caddcl’ => array(),

‘cadlisp’ => array(),

‘cdfg’ => array(‘cdfg’),

‘cobol’ => array(‘cbl’),

‘cpp’ => array(‘cpp’, ‘hpp’, ‘C’, ‘H’, ‘CPP’, ‘HPP’),

‘csharp’ => array(‘cs’),

‘css’ => array(‘css’),

‘d’ => array(‘d’),

‘delphi’ => array(‘dpk’, ‘dpr’, ‘pp’, ‘pas’),

‘diff’ => array(‘diff’, ‘patch’),

‘dos’ => array(‘bat’, ‘cmd’),

‘gettext’ => array(‘po’, ‘pot’),

‘gml’ => array(‘gml’),

‘gnuplot’ => array(‘plt’),

‘groovy’ => array(‘groovy’),

‘haskell’ => array(‘hs’),

‘html4strict’ => array(‘html’, ‘htm’),

‘ini’ => array(‘ini’, ‘desktop’),

‘java’ => array(‘java’),

‘javascript’ => array(‘js’),

‘klonec’ => array(‘kl1’),

‘klonecpp’ => array(‘klx’),

‘latex’ => array(‘tex’),

‘lisp’ => array(‘lisp’),

‘lua’ => array(‘lua’),

‘matlab’ => array(‘m’),

‘mpasm’ => array(),

‘mysql’ => array(‘sql’),

‘nsis’ => array(),

‘objc’ => array(),

‘oobas’ => array(),

‘oracle8’ => array(),

‘oracle10’ => array(),

‘pascal’ => array(‘pas’),

‘perl’ => array(‘pl’, ‘pm’),

‘php’ => array(‘php’, ‘php5’, ‘phtml’, ‘phps’),

‘povray’ => array(‘pov’),

‘providex’ => array(‘pvc’, ‘pvx’),

‘prolog’ => array(‘pl’),

‘python’ => array(‘py’),

‘qbasic’ => array(‘bi’),

‘reg’ => array(‘reg’),

‘ruby’ => array(‘rb’),

‘sas’ => array(‘sas’),

‘scala’ => array(‘scala’),

‘scheme’ => array(‘scm’),

‘scilab’ => array(‘sci’),

‘smalltalk’ => array(‘st’),

‘smarty’ => array(),

‘tcl’ => array(‘tcl’),

‘vb’ => array(‘bas’),

‘vbnet’ => array(),

‘visualfoxpro’ => array(),

‘whitespace’ => array(‘ws’),

‘xml’ => array(‘xml’, ‘svg’),

‘z80’ => array(‘z80’, ‘asm’, ‘inc’)

WP-Syntax 优化本领

冬镜说句忠心话WP-Syntax默许的css款式是比拟丑陋

以是冬镜倡导仍旧本人发端去窜改了一下额

即使你须要冬镜给你写的CSS款式

不妨运用如次代码掩盖该插件的wp-syntax/wp-syntax.css的代码

.wp_syntax {

color:#100;

background-color:#f9f9f9;

border:1px solid #EBEBEB;

margin:0 0 1.5em 0;

overflow:auto;

}

.wp_syntax {

overflow-x:auto;

overflow-y:hidden;

padding-bottom:expression(this.scrollWidth > this.offsetWidth ? 15:0);

width:99%;

}

.wp_syntax table {

border:none;

border-collapse:collapse;

margin:0;

padding:0;

width:100% !important

}

.wp_syntax caption {

padding:2px;

width:100%;

background-color:#def;

text-align:left;

font-family:Monaco;

font-size:13px;

line-height:20px;

}

.wp_syntax caption a {

color:#1982d1;

text-align:left;

font-family:Monaco;

font-size:13px;

line-height:20px;

text-decoration:none;

}

.wp_syntax caption a:hover {

color:#1982d1;

text-decoration:underline;

}

.wp_syntax div,.wp_syntax td {

border:none;

text-align:left;

padding:0;

vertical-align:top;

}

.wp_syntax td.code {

background:none;

line-height:normal;

white-space:normal;

padding-left:10px;

}

.wp_syntax pre {

background:transparent;

margin:0;

padding:0;

width:auto;

float:none;

clear:none;

overflow:visible;

font-family:Monaco;

font-size:13px;

line-height:20px;

white-space:pre;

}

.wp_syntax td.line_numbers pre {

border-right:3px solid #6CE26C;

background-color:#E7E5DC;

color:gray;

width:20px;

padding:0 5px;

text-align:right;

}

冬镜更倡导你将上头的代码增添到你的中心style.css 文献中

而后在functions.php中增添底下的代码而且废除WP-Syntax加载的css文献

如许纵然你此后晋级了插件也能保持你此刻运用的款式

if (

has_action( ‘wp_print_styles’, ‘wp_syntax_style’ ) )

{

remove_action( ‘wp_print_styles’, ‘wp_syntax_style’ );

};

免责声明: 本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
转载请注明出处:
网赚 » WordPress作品页代码高亮插件WP-Syntax

提供最优质的资源集合

赞助会员 了解详情