prismjs
This module enables the Prism Js plugin from prismjs.com in your WYSIWYG. It includes the highlightjs library and all available styles for it. If you've ever wanted to drop code examples in your Drupal content and have it highlighted in a pretty format, this is for you. Since that project relies on WYSIWYG module, and this one only requires D9/10 core, it made sense to rename it.
This module provides a way to allow editors to insert styled components into CKEditor5 without having
to grant the editors permission.
Basic Usage
After completing the moduel installation, go to the filter format you want to configure (must be using CKEditor5). Drag the Prism Js icon into the active toolbar, and the config form will
appear below with a syntax highlighting style and supported languages
option. Configure the languages and theme from here /admin/config/content/prism-js. By default, few are checked for you. Uncheck ones you won't need, it's optional. This only controls the options in the dialog window of CKEditor5 when inserting a source code.
Note that your filter format must support the use of pre and code tags under allowed tags as well, if using anything other than Full HTML. You also need to configure the HTML filter (if Limit Allowed Tags is enabled) to allow the class attribute like so. Drupal 9 ships with CKEditor 5, so it depends on the ckeditor module from core.
Support
Please post bug reports, feature requests and support requests to the Prism Js module issue queue. If you met any problems with this module - feel free to create an issue.
Demo
- Go to https://simplytest.me/project/prismjs.
- Click "Launch Sandbox".
- Install Drupal as normal.
- Enable "Prism Js" module, and any optional modules you wish to try out.
- Go to /admin/config/content/prism-js and configure available languages and default theme
- Go to admin/config/content/formats/manage/full_html and drag the Prism js icon on the active toolbar
- Add content with text editor click on the prismjs icon and add your code. Double click on the code snippet to edit the source code.