Project description

Wagtail Code Block

Wagtail Code Block is a syntax highlighted block for source code for the Wagtail CMS. It features real-time highlighting in the Wagtail editor, the front end, line numbering, and support for PrismJS themes.

It uses the PrismJS library both in Wagtail Admin and the website and requires jQuery.

Example Usage

You can also force it to use a single language by providing a language code which must be included in your WAGTAIL_CODE_BLOCK_LANGUAGES setting:

code=CodeBlock(label='Bash Code',language='bash')

Screenshot of the CMS Editor Interface

Installation & Setup

To install Wagtail Code Block simply run:

pip install wagtailcodeblock

And add wagtailcodeblock to your INSTALLED_APPS setting:

INSTALLED_APPS=[...'wagtailcodeblock',...]

Django Settings

Themes

Wagtail Code Block defaults to the PrismJS "Coy" theme, which looks good with Wagtail's CMS editor design. You can choose a different theme by configuring WAGTAIL_CODE_BLOCK_THEME in your Django settings. PrismJS provides several themes:

For example, in you want to use the Solarized Light theme: WAGTAIL_CODE_BLOCK_THEME = 'solarizedlight'
If you want to use the Default theme: WAGTAIL_CODE_BLOCK_THEME = None

Languages Available

You can customize the languages available by configuring WAGTAIL_CODE_BLOCK_LANGUAGES in your Django settings.
By default, it will be set with these languages, since most users are in the Python web development community: