Wagtail Pygments Block
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 }} {% if block.value.caption %} <!-- Caption --> <figcaption> {{ block.value.caption }} </figcaption> {% endif %} {% 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/.
Metadata
Release files for wagtail-pygments 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wagtail-pygments-0.1.1.tar.gz | 3.0 kB | Without provenance | Details for wagtail-pygments-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wagtail_pygments-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for wagtail_pygments-0.1.1-py3-none-any.whl |
Total release size: 7.5 kB
Release files / wagtail-pygments-0.1.1.tar.gz
| Download URL | wagtail-pygments-0.1.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf59a611f2b4167c601e2066ec82bac3ab95d66b909f25be3786a1047e2b49b4
|
|
BLAKE2b-256 checksum How to use checksums |
7f91c3fe6abee055de3b41f3cfdd85dd92a1c327ab81892cdd109e8d76ddfafa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Release files / wagtail_pygments-0.1.1-py3-none-any.whl
| Download URL | wagtail_pygments-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9c2a892b247a47cfa8404655e1dfc3d43e6a65d04be2e8383a9fbd9894fdb6f
|
|
BLAKE2b-256 checksum How to use checksums |
3e6ec0faed843149493b5366c023ff1af4153a38a806db6386ce9d92d72934b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Security for wagtail-pygments 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.