wp-syntax-highlighter
WP-Syntax-Highlighter is a WordPress plugin that brings the Highlight.js based source code syntax highlighting to WordPress. This plugin is compatible with any other syntax highlighter plugins that use Syntax Highlighter , GeSHi or Prismjs . Credits Thanks to Ivan Sagalaev and the highlight.js team
WP-Syntax-Highlighter is a WordPress plugin that brings the Highlight.js based source code syntax highlighting to WordPress. This plugin is compatible with any other syntax highlighter plugins that use Syntax Highlighter , GeSHi or Prismjs .
Credits
- Thanks to Ivan Sagalaev and the highlight.js team for this excellent library.
- 01Click Plugins > Add New in the WordPress admin panel.
- 02Search for “wp-syntax-highlighter” and install.
Customization
The plugin comes bundled with all the themes provided by Highlight.js. Use the Theme dropdown to change the selected theme.
Additionally the plugin checks for a custom.css in your current theme’s directory at {current_theme}/wp-syntax-highlighter/custom.css .
If this CSS file is present it will be added to the page automatically. You can override any builtin theme’s styles in this manner.
To use a completely custom theme use the Custom option in Theme dropdown. Now only your current theme’s custom.css will be used to style the code blocks.
Shortcodes
Each language gets it’s own shortcode. You can use this to add code blocks for that language into your posts.
For instance to add some PHP code into your post use,
[php] foreach ($requirements as $requirement) { $result = array( 'satisfied' => $requirement->check(), 'requirement' => $requirement ); array_push($results, $result); if (!$result['satisfied']) { $success = false; } } [/php]
Supported Languages
The following languages are currently supported by highlight.js.
- 031c
- 04Actionscript
- 05Apache
- 06Applescript