The code plugin¶
The code plugin provides highlighting for programming code.
The plugin uses Pygments as backend to perform the highlighting:
The color theme can be configured in the settings.
Install the dependencies via pip:
pip install django-fluent-contents[code]
This installs the Pygments package.
Add the following settings to
INSTALLED_APPS += ( 'fluent_contents.plugins.code', )
No settings have to be defined. For further tuning however, the following settings are available:
FLUENT_CODE_DEFAULT_LANGUAGE = 'html' FLUENT_CODE_DEFAULT_LINE_NUMBERS = False FLUENT_CODE_STYLE = 'default' FLUENT_CODE_SHORTLIST = ('python', 'html', 'css', 'js') FLUENT_CODE_SHORTLIST_ONLY = False
Define which programming language should be selected by default.
This setting is ideally suited to set personal preferences. By default this is “HTML”, to be as neutral as possible.
Define whether line number should be enabled by default for any new plugins.
The desired highlighting style. This can be any of the themes that Pygments provides.
Each style name refers to a python module in the
The styles provided by Pygments 1.4 are:
- bw (black-white)
- vs (Visual Studio colors)
This setting cannot be updated per plugin instance, to avoid a mix of different styles used together. The entire site uses a single consistent style.
The plugin displays a shortlist of popular programming languages in the “Language” selectbox, since Pygments provides highlighting support for many many programming languages.
This settings allows the shortlist to be customized.
Enable this setting to only show the programming languages of the shortlist. This can be used to simplify the code plugin for end users.