About Code Blocks Textformatter
Converts content within backticks into code blocks.
Category | Text Formatters Textformatter modules that provide run-time formatting for blocks of text (typically used with Text/Textarea fields). |
---|---|
Release State | Beta Close to stable, but users are advised to be cautious and test thoroughly.* |
Author | |
Module Version | 0.2.0 |
Class Name | TextformatterCodeBlocks |
Compatibility | 2.7, 3.0 |
Date Added | February 17, 2018 |
Last Updated | January 16, 2019 |
Recommended By | New recommendations may take up to 1 day to appear. |
Instructions
This module's files should be placed in /site/modules/TextformatterCodeBlocks/
How to install or uninstall modules
README
TextformatterCodeBlocks
ProcessWire Textformatter module for enabling Markdown style code blocks for text or RTE fields.
Note: this is not a complete Markdown implementation, but rather a home-baked implementation of just one small part of the Markdown syntax. For full Markdown support, check out the TextformatterMarkdownExtra module, bundled with ProcessWire releases by default.
Getting started
- Copy (or clone) the TextformatterCodeBlocks directory to /site/modules/
- Go to Admin > Modules, hit "Refresh", and install TextformatterCodeBlocks
- Enable "Code Blocks Textformatter" for fields in which you wish to use code blocks
IMPORTANT: if you use Code Blocks Textformatter with a regular text or textarea field, make sure that you enable HTML Entity Encoder or use another method of escaping entities!
Code blocks
Code blocks should work fine when wrapped in
or
tags, so you can use them with RTE, such as CKEditor. This module supports two types of code blocks: fenced and inline.
Fenced code blocks
Simple example:
<?php
echo "This is a fenced code block.";
With fenced code blocks you can also specify the language for a syntax highlighter:
<?php
echo "This PHP code is easier for a syntax highlighter to identify.";
The end result of fenced code blocks looks like this:
<?php
echo "This PHP code is easier for a syntax highlighter to identify.";
Inline code blocks
While fenced code blocks are great for longer code snippets, sometimes `<?php echo "inline code blocks"; ?>` make more sense.
The end result of inline code blocks looks like this:
While fenced code blocks are great for longer code snippets, sometimes <?php echo "inline code blocks"; ?>
make more sense.
Enabling syntax highlighter
Though syntax highlighting is not necessary for this module to work, it can be really helpful for your end users. You can use any syntax highlighter, but I would recommend Prism.js.
For detailed instructions on enabling Prism.js on your site, please visit http://prismjs.com/.
Comments
No comments yet. Be the first to post!
Post a Comment
Your e-mail is kept confidential and not included with your comment. Website is optional.
- Admin Helpers
- Authentication
- Core Modules
- Development Tools
- Email/WireMail
- Field Types
- Import/Export
- Input Fields
- Language Modules
- Language Packs
- Logs/Monitoring
- Markup Generation
- Photo/Video/Audio
- Premium Modules
- Process Modules
- Proof of Concept
- SEO/Accessibility
- Site Profiles
- Social, Feeds, Services
- Text Formatters
- Other Modules
- Users and Access
Disclaimer
*Use modules at your own risk. There are no guarantees or warranties. It is recommended that you backup your site and database before installing new modules.