To add source code formatting in CKEditor, follow the steps given below:
Download the ‘Code Snippet plugin’ and extract it to the ‘plugins’ directory of CKEditor
Alter the
config.js
file by adding the ‘code snippet plugin’ to the ‘extra Plugins’ option:
Add a button for inserting code snippets in the toolbar:
Add the ‘Code Snippet CSS’ file in your HTML page to style the code by linking it to the
highlight.js
library used by the plugin:
Now, you should see the Code Snippet button in the toolbar, allowing you to insert formatted source code.