EnlighterJS provides a full TinyMCE editor integration via EnlighterJS/Plugin.TinyMCE. This allows you to add/edit code to your content seemlessly.
The examples on this page are showing the editor plugin added to WordPress via Enlighter Plugin - it also works standalone!
- Move the Cursor to the position you want to insert the code snippet
- Click on the
Enlighter Code Insert
Button on the upper right of the toolbar - Paste your snippet into the text-area
- Select the language of your snippet (javascript in this example)
- Select "Left-Align-Indentation" - this will strip the unnecessary code indentation (marked in the example)
- Click OK
- You can edit the snippet directly in the Visual Editor at any time
- Publish your post!
Sometime you already have some code within your posts you want to highlight. In this case Enlighter comes with its own Formats which allows you to highlight a selected text in the Visual Editor.
- Expand the Editor Toolbar
- Select the content you want to highlight
- Goto
Formats -> Enlighter Codeblocks
and select the language - Publish your post!
Enlighter 3.5 comes with its own tab-alignment addon which allows you to align your code directly within the editor (optional feature).
Requirement: Set Enlighter -> Editing -> Visual Editor -> Tweaks -> Enable Tab Indentation
- Move Right: Select code + press tab key
- Move Left: Select code + press shift+tab key
Enlighter allows you to highlight codeblocks as well as inline snippets out-of-the-box. Inline-Code is often used to highlight small pieces of code diretly within a larger textblock.
- Expand the Editor Toolbar
- Select the content you want to highlight
- Goto
Formats -> Enlighter Inline
and select the language - Publish your post!
Sometime you may need some advanced features like
- Disable Linenumbers
- Change Theme of a individual codeblock
- Set a linenumber offset
- Highlight special lins
- Create Codegroups
this settings are available after the code-snippet has been added to the editor by using the Enlighter Code Settings
Button
- Move the Cursor into an existing Enlighter Codeblock (or inline)
- The
Enlighter Code Settings
Button will appear on the upper right side of the codeblock and on the upper right of the toolbar - Click on the
Enlighter Code Settings
Button - An advanced settings dialog will be opened
- Change the Theme
- Set a linenumber-offset
- Highlight a special line
- Click OK
- Publish your post!
In some cases, your code example rely on a several different languages. For example HTML, CSS and Javascript. It can be helpful to group this snippets together.
- Add some code snippets to your post
- Click on the
Enlighter Code Settings
Button to edit a codeblock - Add a
Codegroup Identifier
to each codeblock you want to group together (has to be unique for each group) - Add an optional
Codegroup Title
to each codeblock - its used as the tabname