Create code highlighter without plugin by use “google-code-prettify” in WordPress

1. Put the following code to your theme footer.php within <body></body> tag:

* Or you could put the code to header tag (header.php) if you wanna load it earlier than this.

 

2. When you wanna highlight a code, switch to text view in WordPress editor, and put your code snippets inside of a “pre” tag: <pre class=”prettyprint”>//code here</pre>

Or a “code” tag: <code class=”prettyprint”>//code here</code>

 

The result should look like this(Notice that the line number appears in every fifth line by default):

Create code highlighter without plugin by use “google-code-prettify” in WordPress

 

</catmee> 文章全部原创、谢绝转载,作者「BianLei」,如果喜欢欢迎分享链接,相关内容参见本站版权声明
如果您觉得本站的存在对您多少有所帮助,可以用手机支付宝扫一扫以下二维码支付任意金额作为支持:支付宝。你的大名会出现在这个页面
本站相关:QQ空间 | Facebook
Tagged . Bookmark the permalink.

Comment Anonymously? No Problem! | 可以匿名评论了我会说?

Fill up Email address to subscribe reply and display your avatar from Gravatar (If any)
填写邮箱即可显示您在Gravatar的头像