A block render syntax highlighter for Wagtail CMS.
Project description
A block render syntax highlighter for Wagtail CMS.
Install
pip install -i wagtail-pygments
Example Usage
Use with StreamBlock:
from wagtail_pygments.blocks import CodeBlock class ContentStreamBlock(StreamBlock): heading = TextBlock() paragraph = TextBlock() code = CodeBlock(label='Code')
Use with StreamField:
from wagtail_pygments.blocks import CodeBlock class PostPage(Page): body = StreamField([ ('paragraph', RichTextBlock()), ('image', ImageChooserBlock()), ('embed', EmbedBlock()), ('code', CodeBlock()) ])
Example for django template:
{% load static %} <link rel="stylesheet" href="{% static 'css/monokai.css' %}"> {% for block in page.body %} {% if block.block_type == "code" %} {{ block.value.code }} {% else %} {{ block.value }} {% endif %} {% endfor %}
Languages
Configuring WAGTAIL_CODE_BLOCK_LANGUAGES in your Django settings:
WAGTAIL_CODE_BLOCK_LANGUAGES = ( ('cpp', 'C++'), ('java', 'Java'), ('python3', 'Python 3'), ('bash', 'Bash/Shell'), ('javascript', 'Javascript'), ('css', "CSS"), ('html', "HTML"), ('julia', "Julia"), ('nginx', "Nginx configuration file"), ('numpy', "NumPy"), ('django', "Django"), ('jinja', "Jinja"), ('docker', "Docker"), ('jinja', "Jinja"), ('yaml', "YAML"), ('json', "JSON"), ('plpgsql', "PL/pgSQL"), ('psql', "PostgreSQL console (psql)"), )
Can check full list in https://pygments.org/docs/lexers/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for wagtail_pygments-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f097f20b22dc899758d45c8ceb557ba37a115dcb1f6580d67276feb9c4059517 |
|
MD5 | 23d38bf8bd562104d84539a4321ea9fa |
|
BLAKE2b-256 | 4dec3f7d35eaffc1313a824ea60cea61b16959155e80acd2cdc1413f0eae4ab2 |