A syntax highlighter filter for Moodle with the choice of either EnlighterJS or SyntaxHighlighter as the 'engine'. The administrator has 'preview' settings to see what the look will be on example code before the saving.
When active, content with a 'code' tag or 'pre code' tags within a course, module or block will be highlighted. Specifically between the Course and Block contexts.
- Syntax Highlighting.
Prior to version 39.1.0, the 'pre' tag was accepted on its own for code to be highlighted. This proved problematic with the need to have non-code preformatted but not highlighted. To highlight code now, please use the 'code' tag, and surround with a 'pre' tag to indicate a block of code. With 'EnlighterJS', using a 'code' tag on its own indicates 'inline' code. 'SyntaxHighlighter' will highlight the code in a block regardless of if there is an enclosing 'pre' tag.
Please add any configuration attributes to the 'code' tag. Such as 'EnlighterJS - HTML Attribute Options (local)' or for SyntaxHighlighter, please look at the information on the settings page.
<code data-enlighter-language="java" class="brush: java">System.out.println("SynHi");</code>
<pre><code data-enlighter-language="java" class="brush: java">
package test;
public class Test {
private final String name = "Java program";
public static void main (String args[]) {
Test us = new Test();
System.out.println(us.getName());
}
public String getName() {
return name;
}
}
</code></pre>
The SynHi filter is 'free' software under the terms of the GNU GPLv3 License, please see 'COPYING.txt'. It contains third party 'highlighers' which are licensed differenty, see 'Highlighters'.
It can be obtained for free from:
- https://moodle.org/plugins/filter_synhi?lang=pl
- https://github.com/gjbarnard/moodle-filter_synhi/releases
You have all the rights granted to you by the GPLv3 license. If you are unsure about anything, then the FAQ - www.gnu.org/licenses/gpl-faq.html - is a good place to look.
If you reuse any of the code then I kindly ask that you make reference to the filter.
If you make improvements or bug fixes then I would appreciate if you would send them back to me by forking from https://github.com/gjbarnard/moodle-filter_synhi and doing a 'Pull Request' so that the rest of the Moodle community benefits.
- EnlighterJS - https://github.com/EnlighterJS/EnlighterJS - Mozilla Public License 2.0 (MPL-2.0).
- SyntaxHighlighter - https://github.com/syntaxhighlighter/syntaxhighlighter - MIT licensed.
As SynHi is licensed under the GNU GPLv3 License it comes with NO support. If you would like support from me then I'm happy to provide it for a fee (please see my contact details above). Otherwise, the 'General plugins' forum is an excellent place to ask questions.
If you'd like to sponsor, get support or fund improvements, then please do get in touch via:
- gjbarnard | Gmail dt com address.
- GitHub | Please outline your issue / improvement on '[GitHub](https://github.com/gjbarnard/moodle-filter_synhi /issues)'.
- @gjbarnard | 'X'.
This version works with:
- Moodle 4.2 version 2023042400.00 (Build: 20230424) and above within the 4.2 branch.
- Moodle 4.3 version 2023100900.00 (Build: 20231009) and above within the 4.3 branch.
- Moodle 4.4 version 2024042200.00 (Build: 20240422) and above within the 4.4 branch.
- Moodle 4.5 version 2024100700.00 (Build: 20241007) and above within the 4.5 branch.
Please ensure that your hardware and software complies with 'Requirements' in 'Installing Moodle' on:
- Ensure you have the version of Moodle as stated above in 'Required version of Moodle'. This is essential as the filter relies on underlying core code that is out of my control.
- Login as an administrator and put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator.
- Copy the extracted 'synhi' folder to the '/filter/' folder.
- Go to 'Site administration' -> 'Notifications' and follow standard the 'plugin' update notification.
- Put Moodle out of Maintenance Mode.
- Ensure you have the version of Moodle as stated above in 'Required version of Moodle'. This is essential as the filter relies on underlying core code that is out of my control.
- Login as an administrator and put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator.
- Make a backup of your old 'synhi' folder in '/filter/' and then delete the folder.
- Copy the replacement extracted 'synhi' folder to the '/filter/' folder.
- Go to 'Site administration' -> 'Notifications' and follow standard the 'plugin' update notification.
- If automatic 'Purge all caches' appears not to work by lack of display etc. then perform a manual 'Purge all caches' under 'Home -> Site administration -> Development -> Purge all caches'.
- Put Moodle out of Maintenance Mode.
- Put Moodle in 'Maintenance Mode' so that there are no users using it bar you as the administrator.
- Go to Site administration -> Plugins -> Filters -> Manage filters.
- Click on 'Uninstall' and follow the on screen instructions.
- Put Moodle out of Maintenance Mode.
Before reporting an issue, please ensure that you are running the current version for your release of Moodle. It is essential that you are operating the required version of Moodle as stated at the top - this is because the filter relies on core functionality that is out of its control.
I operate a policy that I will fix all genuine issues for free. Improvements are at my discretion. I am happy to make bespoke customisations / improvements for a negotiated fee.
It is essential that you provide as much information as possible, the critical information being the contents of the filter's version.php file. Other version information such as specific Moodle version, theme name and version also helps. A screen shot can be really useful in visualising the issue along with any files you consider to be relevant.
Report issues on: https://github.com/gjbarnard/moodle-filter_synhi/issues
See Changes.md
iframe resize: https://stackoverflow.com/questions/9975810/make-iframe-automatically-adjust-height-according-to-the-contents-without-using
G J Barnard MSc. BSc(Hons)(Sndw). MBCS. CEng. CITP. PGCE.
- Moodle profile | Moodle.org
- @gjbarnard | X
- Web profile | About.me
- Website | Website