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:
567 sites
26 fans
Current versions available: 3

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:


(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.


  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.

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.


Screenshot #0
Screenshot #1
Screenshot #2


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

Comments RSS

Show comments
  • Thu, Feb 20, 2020, 4:53 PM
    Hi Jan, it isn't, though it does need updating, and it's on my loooong todo list. It does work on M3.6 because that's what we're currently using. I've changed the settings to you should be able to download it from the site.
  • Wed, Apr 8, 2020, 9:21 PM
    I can change a style of Syntax Highlighter in plugin's settings only globally. Is there any way to use different styles in different context ex. courses?
  • Wed, Apr 8, 2020, 10:04 PM
    Hi Piotr,
    unfortunately there isn't. If you think there's a way to do it, and can contribute some code, that would be fab. Feel free to head over to the github page. Thanks.
  • Fri, May 1, 2020, 12:24 AM
    What's about M3.7?
  • Fri, May 1, 2020, 12:36 AM
    Forget it
    I took the zip and it seems to work on 3.7.5
  • Fri, May 1, 2020, 6:58 PM
    Hi Jean-Pierre, I tend to only confirm it works for versions of Moodle I have personally tried, but between versions shouldn't massively change, so it should work. Thanks for the confirmation, I'll update the plugin info to say it works on 3.7.
  • Tue, Jun 16, 2020, 3:16 PM
    Unfortunatly we use Moodle 3.8. When will this great Plugin available for Moodle 3.8?
  • Thu, Aug 27, 2020, 8:27 PM
    I succesfully test it on Moodle 3.9.1 using the tripple backticks.
  • Wed, Dec 9, 2020, 10:14 PM
    I would like to display code including html tags. Could this plugin be made to replace the "<" and ">" signs? Or is there maybe another trick to accomplish this?
  • Fri, Jan 22, 2021, 9:24 PM
    I tested it on 3.10.0, it works fine with the triple backticks.
  • Fri, May 14, 2021, 5:30 AM
    Hi Mark is there any possibility to force an specific syntax? Im posting wxmaxima code and sometimes renders fine others dont. Thanks!
  • Fri, May 14, 2021, 3:26 PM
    Hi Martin, yes you can force the language by using the following syntax:
    echo "Hello world!";
    At the moment I've not included maxima, but there might be something that's similar.
    The list of languages and help on the syntax is in the readme file which you can also read on the github page:
  • Sat, May 15, 2021, 12:00 AM
    Thanks a lot Mark! My bad not to explore READMEmd in github ;)
  • Mon, Jan 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
  • Mon, Jan 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 -
1 2
Please login to post comments