A new plugin is available to add syntax highlighting using Highlight.js.
The plugin automatically highlights <pre><code> blocks in your posts and supports a wide range of programming languages. The tinyMCE editor will add that automatically when you choose to insert a code sample section.
Write code snippets inside <pre><code> tags. You can optionally add a language class for better accuracy.
Example (JavaScript):
<pre><code class="language-javascript">
function hello() { console.log("Hello, world!"); }
</code></pre>
Example (ColdFusion):
<pre><code class="language-cfml">
<cfset message = "Hello, world!">
<cfoutput>#message#</cfoutput>
</code></pre>
If no class is specified, Highlight.js will attempt to detect the language automatically.
Theme → there is no UI to set the theme at the moment, but you can add the preference directly to the database. The default theme is a11y-light
INSERT INTO `[your prefix]setting` (`path`, `name`, `value`, `blog_id`, `type`)
VALUES ('plugin/highlightjs', 'theme', 'atom-one-dark', 'default', 'string');
Make sure your blog theme includes <pre> and <code> styles that don’t conflict with Highlight.js CSS.
If you copy code from editors or IDEs, clean up extra markup before publishing.
This plugin is intended for technical blogs where code readability is important. Highlight.js provides consistent formatting across browsers and devices without additional setup.