Moodle Plugins directory: Syntax Highlighter | Moodle.org
Syntax Highlighter
This is a filter plugin that uses a 3rd party Javascript module called highlight.js to make your code look like something you'd see in an IDE.
Once activated, you just need to wrap your code in:
<pre><code>code</code></pre>
(You will need to activate html mode in Atto), or wrap your code in triple backticks (like MarkDown) ``` and the javascript will style it.
The settings allows you to choose which style to use.
Install
- Unzip
- Copy contents to
/filter/syntaxhighlighter
- Activate from Manage filters.
Change requests
Since this is a 3rd party plugin, any change requests that relate to the the styles and features of the highlighting should be directed to the plugin author.
Before you ask...
Can I specify which language I'm using?
You don't need to, the plugin detects that itself. However, you can choose the language by adding it after the backticks. e.g.
```lang:php;;
echo "My PHP code";
```
Or, by adding it to the <code> class attribute:
<pre><code class="lang-php">echo "My PHP code";</code></pre>
Can I have line numbering?
No. This isn't a feature of the javascript plugin. And probably isn't going to be implemented.
Can I use some other highlighting plugin?
I might implement the option of using various hightlighting plugins in the future - such as GeSHi. But this suits my needs for now. You're welcome to do a pull request with any adaptions you would like to add.
is there a way not to interpret the html tags ? When including them into code, they are interpreted and not displayed as code. Thanks
thanks
thank you for any contributions for this great plugin.
I would like to know, did you plan a new release for Moodle 4.x and when will it be published?
Best regards,
Anisa
I use it on Moodle 4.1, and it works great. But I also want to update my platform to Moodle 4.3 version and continue to use your plugin there. Is there any opportunity to use your plugin on Moodle 4.3 or maybe there are other paths to highlight a syntax? Are you going to make a new version of your plugin compatible with Moodle 4.3?
The plugin works like a charm on Moodle 4.5.
I was wondering if the plugin is still compatible with the latest versions of Moodle, such as 4.3 or 4.5, as mentioned above.