Drupal Technical
[Drupal] How to enable syntax highlighter in ckeditor for Drupal
Hi guys, here I am going to explain how to enable syntax highlighting in ckeditor. Lets assume that you already have a Drupal 7 installation ready and CKeditor also (https://www.drupal.org/project/ckeditor).
I am going to use Drupal GeSHi module to highlight sytanx. For that you have to do the following steps:
- 1) Download and install Drupal GeSHi module(https://www.drupal.org/project/geshifilter)
- 2) Download third party library dependency: GeSHi (only download 1.0.x versions ,because others are not supported)
- 3) Then goto Configuration > Content authoring > Text formats
- 4) Edit Full HTML and Filtered HTML options and mark "GeSHi filter" option in that.
- 5) To configure filter options; administer > site configuration > geshifilter
- 6) Now you can use the tags in the editor
for example for a java code:
The basic usage (with the default settings) is:
for (int i; i<10; ++i) {
dothisdothat(i);
}
When language tags are enabled (like "<java>" for Java) you can also do
for (int i; i<10; ++i) {
dothisdothat(i);
}
This is how you can highlight syntax in cke editor. Hope it helps.