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空间 | YouTube ★★★ 打赏:支付宝 ★★★
Tagged . Bookmark the permalink.

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

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