Socket
Socket
Sign inDemoInstall

wagtail-pygments

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wagtail-pygments

A block render syntax highlighter for Wagtail CMS.


Maintainers
1

Wagtail Pygments Block

.. image:: https://badge.fury.io/py/wagtail-pygments.svg :target: https://badge.fury.io/py/wagtail-pygments

A block render syntax highlighter for Wagtail CMS.

Install

pip install -i wagtail-pygments

Example Usage

  1. Use with StreamBlock::

    from wagtail_pygments.blocks import CodeBlock

    class ContentStreamBlock(StreamBlock): heading = TextBlock() paragraph = TextBlock() code = CodeBlock(label='Code')

  2. Use with StreamField::

    from wagtail_pygments.blocks import CodeBlock

    class PostPage(Page): body = StreamField([ ('paragraph', RichTextBlock()), ('image', ImageChooserBlock()), ('embed', EmbedBlock()), ('code', CodeBlock()) ])

  3. Example for django template::

    {% load static %}

    {% for block in page.body %} {% if block.block_type == "code" %} {{ block.value.code }} {% if block.value.caption %}

    {{ block.value.caption }} {% 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/.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc