Mes essais sur les différents plugins
PRISM SyntaxHighlighter
Fournisseur
https://www.andrehotzler.de/en/projects/prism-prismjs-com-syntaxhighlighter-for-joomla.html
Description
Ce plugin est basé sur https://prismjs.com/
un "syntaxhighlighter" codé en javascript
La syntaxe
<pre class="langage-php" > $variable = "Ceci est un message test !";</pre>
Le résultat
$variable = "Ceci est un message test !";
JO's Code Highlighter
Description
JO's Code Highlighter est un plugin pour Joomla qui permet d'habiller le code avec une coloration syntaxique.
La coloration syntaxique est une fonctionnalité des éditeurs de texte et IDE qui applique des couleurs et formats pour distinguer les éléments de code, améliorant ainsi la lisibilité et facilitant l'identification des erreurs
La syntaxe
<pre xml:lang="javascript" lines="true" > var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-19694431-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </pre>
Le résultat
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-19694431-1']);
- _gaq.push(['_trackPageview']);
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
|
Attention à bien placer xml:lang juste après la balise pre |
Site github
J'avais fait un "fork" du repo principal non mis à jour depuis 12 ans !!!
https://github.com/JLTRY/Joomla-GeSHi
J'ai décidé de créer un nouveau plugin hébergé aussi sur github
https://github.com/JLTRY/jocodehighlight
SyntaxHighlighter
Fournisseur
|
http://alexgorbatchev.com/SyntaxHighlighter/ Le site n'existe plus. Le plugin n'utilise que du javascript, contrairement à la famile geshi qui elle utilise du php. Le site ne fonctionne pas très bien. |
La syntaxe
<pre class="brush:php;gutter:false;toolbar:false"> public static function getpost() { if (version_compare(JVERSION, '4.0', 'ge')){ return JFactory::getApplication()->input->getArray(array()); } else { return call_user_func_array('AttachmentsHelper::get', ['post']); } } </pre>
Le résultat
public static function getpost() { if (version_compare(JVERSION, '4.0', 'ge')){ return JFactory::getApplication()->input->getArray(array()); } else { return call_user_func_array('AttachmentsHelper::get', ['post']); } }
Correctif
J'ai eu un souci sous Internet Explorer
J'ai fait un correctif dans syntaxhighlighter:
JFactory::getDocument()->addScriptDeclaration($js); //added JFactory::getDocument()->addScript( 'plugins/content/syntaxhighlighter/js/shBrushPhp.js' ); JFactory::getDocument()->addScript( 'plugins/content/syntaxhighlighter/js/shBrushCss.js' );
Liens utiles
- PRISM (prismjs.com) SyntaxHighlighter for Joomla! - Andre Hotzler EDV-Dienstleistungen
- Joomler SyntaxHighlighter - Joomla! Extensions Directory
- syntaxhighlighter/syntaxhighlighter: SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript.
- SyntaxHighlighter-3.0.83-after-AJAX-call-Cant-find-brush-for-BRUSH-fix
- occams-razor-and-brushes
- GeSHi - Generic Syntax Highlighter :: Home