A Wagtail CMS StreamField block for displaying source code with real-time PrismJS syntax highlighting in both admin and frontend.
Wagtail Code Block is a Django/Wagtail extension that adds a StreamField block for displaying source code with syntax highlighting. It solves the problem of presenting code snippets in Wagtail-powered websites by providing real-time highlighting in both the admin interface and frontend using PrismJS. The package makes it easy for content editors to add properly formatted code without needing technical markup knowledge.
Wagtail CMS developers and content editors who need to display code snippets in their websites. It's particularly useful for technical documentation sites, educational platforms, and developer blogs built with Wagtail.
Developers choose Wagtail Code Block because it provides seamless integration with Wagtail's StreamField system, requires minimal configuration, and offers consistent syntax highlighting across both admin and frontend interfaces. Unlike generic code display solutions, it's specifically designed for Wagtail's architecture and editor workflow.
StreamField code blocks for the Wagtail CMS with real-time PrismJS Syntax Highlighting.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides immediate syntax highlighting in the Wagtail editor as content editors type, enhancing the editing experience without page reloads, as shown in the screenshot.
Uses PrismJS to deliver consistent, beautifully formatted code on the frontend with support for multiple themes like Coy, Dark, and Okaidia, configurable via Django settings.
Includes line numbers and a copy-to-clipboard button by default, both configurable through settings like WAGTAIL_CODE_BLOCK_LINE_NUMBERS and WAGTAIL_CODE_BLOCK_COPY_TO_CLIPBOARD.
Supports dozens of programming languages from Python to YAML, with a customizable language list via WAGTAIL_CODE_BLOCK_LANGUAGES, including esoteric options like Brainfuck and Zig.
The project is hardcoded to use PrismJS, making it difficult to switch to alternative syntax highlighters without forking or significant customization, limiting flexibility.
Version numbers are tied to PrismJS releases (e.g., 1.28.0.X), which can confuse dependency management and require careful matching with Wagtail versions, as noted in installation instructions.
Frontend highlighting relies on PrismJS JavaScript, so it won't work in environments with JS disabled or where server-side rendering is preferred for performance or accessibility.
Designed exclusively for Wagtail's StreamField, so it's unusable for projects outside Wagtail or those needing syntax highlighting in other parts of a Django app without Wagtail.