TLDR; Write posts in WordPress using github flavored markdown without wanting to kill yourself.
Blogging about code in WordPress has historically been a HUGE pain in the ass.
TinyMCE and the WordPress visual editor garble your code like it's their job.
I've tried every single syntax highlighter plugin in existence.
They all fell short in one way or another.
So like any good developer. I rolled my own.
I made this with a focus on JavaScript and it supports ES6 javascript syntax highlighting and JSX for React code snippets.
If you don't see your language here, make a custom Prism build and replace the prism.js
file.
/wp-admin/profile.php
Syntax highlighting is handled by Prism.
The Markdown parser was shamelessly gutted from JetPack and Evan Solomon's GitHub flavored markdown script
Thanks! =)
// JavaScript!
var greeting = 'What up G'
alert(greeting)
// React BABY!
var ProductItem = React.createClass({
render: function () {
return (
<tr>
<td>{this.props.name}</td>
<td>{this.props.price}</td>
</tr>
);
}
});
// HTML!
<a href="http://davidwells.io">
Wowza!!!!
</a>
/* CSS! */
.ninja {
visibility: hidden;
}
// PHP!
<?php
echo 'Derp';
?>
# Bash script
mkdir lololol && cd lololol
I'm not supporting custom use cases and styles.
You can fork the plugin and do this yourself!
To change CSS, edit the prism.css
file
To change/customize prism edit the prism.js
file.
To add support for more custom post types alter these lines.