Some languages supported by Prism.js are not rendered in the codesample plugin
See original GitHub issueConfiguring custom languages and CSS in the configuration of the codesample is not enough to provide proper rendering for some languages supported by Prism.js
.
To reproduce
Access the following fiddle (using any version of TinyMCE to this day) : http://fiddle.tinymce.com/zagaab
Bug : The JSON sample is not properly highlighted/rendered in the TinyMCE editor.
Expected : With an appropriate configuration, the following rendering is expected :
Explanation The codesample plugin provides its own bundle of Prism :
- 4.x/src/plugins/codesample/main/ts/core/Prism.ts
- master/modules/tinymce/src/plugins/codesample/main/ts/core/Prism.ts
Therefore, even though the codesample plugin can be configured to specify which languages are to be rendered and with which CSS, not all languages will be supported because the rendering engine is missing.
Requested fix
The codesample plugin should provide a configuration to define a custom Prism instance or JS Path to use for the rendering.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Hi,
This feature was added in TinyMCE 5.2, as you can now use the global PrismJS instance to render the codesamples within the editor. This can be enabled with the
codesample_global_prismjs
setting, which then allows custom languages to be used. Here’s an example showing Perl and PowerShell being added: http://fiddle.tinymce.com/6bhaabAs for the plugins mentioned in the second comment, theres already https://github.com/tinymce/tinymce/issues/2771 and https://github.com/tinymce/tinymce/issues/4481 open for that so I’m going to go ahead and close this since the original request has been implemented.
Thanks!
@SantuarioParra this was about using different languages, not themes. Themes are controlled via CSS and as such are reliant on the content CSS you provide. As an example, here’s my example above adapted to use the
dark
PrismJS theme: http://fiddle.tinymce.com/6bhaab/1Anyways, since this is a different issue, if you have any further issues please open a new issue instead. Thanks!