Syntax Highlighter

Filters ::: filter_syntaxhighlighter
Maintained by Mark Sharp
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.
Latest release:
788 sites
401 downloads
34 fans
Current versions available: 4

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

  1. Unzip
  2. Copy contents to /filter/syntaxhighlighter
  3. 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.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

Mark Sharp (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

نظریې وښیئ
  • pitou col
    دونۍ، 31 جنوري 2022، 4:36 PM
    Hello Mark
    is there a way not to interpret the html tags ? When including them into code, they are interpreted and not displayed as code. Thanks
  • Mark Sharp
    دونۍ، 31 جنوري 2022، 4:46 PM
    Hi @pitou col I've just tested this myself, and it works fine. Could you test again with some more details, and post it on the issue tracker - https://github.com/sharpchi/moodle-filter_syntaxhighlighter/issues
    thanks
  • Anisa Dewi
    څلرنۍ، 19 اکتوبر 2022، 8:08 PM
    Hello,
    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
  • Mark Sharp
    څلرنۍ، 19 اکتوبر 2022، 8:38 PM
    Hi Anisa, I've just run the tests against M4.0 and all appears to function as before, so I've included Moodle 4 .0 in the compatibility list.
  • Jean-Pierre Mouret
    درېنۍ، 29 نومبر 2022، 4:23 AM
    I have tested the plugin with 4.1. No problems.
  • Jean-Pierre Mouret
    درېنۍ، 29 نومبر 2022، 4:33 AM
    BTW: All plugins I use under 4.0 also work under 4.1, I think there is no problem. (On git 4.1 has therefore also probably the version 401).
  • Mark Sharp
    درېنۍ، 29 نومبر 2022، 5:20 PM
    Thanks @Jean-Pierre for testing that. I've only just started testing M4.1. I'll bump the compatibility.
  • VietCuong Nguyen
    جمعه، 25 اګست 2023، 8:54 PM
    Anyone being duplicate course data when import this plugin on moodle 4.2.0?
  • Mark Sharp
    جمعه، 25 اګست 2023، 9:18 PM
    Hi Cuong, could you reproduce the steps (with examples) that led to this error please, and report them at https://github.com/sharpchi/moodle-filter_syntaxhighlighter/issues so I can keep a track? thanks
  • Mosaab Alsiddig
    درېنۍ، 13 فبروري 2024، 11:54 PM
    While GeSHi has more advanced options like "copy code" but it has runtime error, that why I uninstalled it and install this great plugin, and it work like a charm in 4.2 and 4.3 , I hope if the developer come back and add more features
  • Elena Virtanen
    درېنۍ، 5 مارچ 2024، 4:05 PM
    Hi Mark! Thank you so much for handy and helpful Syntax highlighter! It's awesome!
    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?
  • Elena Virtanen
    څلرنۍ، 6 مارچ 2024، 4:30 AM
    I withdraw my previous question. Have already updated and tested plugin in Moodle 4.3. It works! موسکا
  • Jean-Pierre Mouret
    پينځنۍ، 21 نومبر 2024، 3:32 AM
    Hi Mark
    The plugin works like a charm on Moodle 4.5.
  • Raymon Akbar
    څلرنۍ، 8 جنوري 2025، 9:50 AM
    Hi All,
    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.
  • Mark Sharp
    پينځنۍ، 9 جنوري 2025، 9:37 PM
    Hi Raymon, I've just updated the plugin for compatibility with M4.1 -> M4.5
1 2 3
Please login to post comments