Nom de la contribution : ColorationSyntaxiqueMatlab
Description : Coloration syntaxique du langage matlab.
Type de contribution : coloration syntaxique
Fonctionne avec : WikiNi 0.4.3
Intégration technique : placer le fichier
coloration_matlab.php dans le répertoire
formatters/
Mainteneur : LordFarquaad
Licence : GPL
Dernière version : 0.1.0
Dernière livraison : 27/12/2004
Accès au code et mise en oeuvre : ColorationSyntaxiqueMatlab
Démonstration : http://fsa.notredomaine.org/wiki/TestColorationMatlab
Intégration au projet WikiNi :
Bugs: signaler ici les bugs
Description détaillée:
Cette coloration utilise le classe
Hightlighter de
WikiNi et essaie d'imiter la coloration de l'éditeur
MatLab.
- Les chaines de carractères sont en rouge foncé (... brun)
- Les commentaires sont mis en vert. Attention: on ne peut pas faire de commentaires commençant par (ou contenant) %% puisque c'est la syntaxe de WikiNi pour délimiter du code...
- les mots cles sont mis en bleu, mais il en manque peut-être... voici la liste que j'ai reprise:
- "..." (plus simple que de le mettre dans les symboles, surtout que s'eût été pour leur donner la même couleur...)
- break
- case
- catch
- continue
- else
- elseif
- end
- for
- function
- if
- return
- switch
- try
- while
Cas problématique:
En matlab, une matrice peut être transposée avec un guillemet, et ceci est difficile à détecter (impossible en tout cas avec la classe
Hightlighter). Par conséquent, s'il y a deux transposées sur la même ligne (ce qui est tout de même assez rare et peut être évité grâce aux points de suspention), la partie entre les guillemets apparaîtra comme une chaine...
Telechargement:
http://contributions-wikini.notredomaine.org/ColorationSyntaxiqueMatlab-v.0.1.0-20041227.zip
Code source:
<?php
/*
colration_matlab.php : coloration syntaxique de matlab dans WikiNi
Copyright 2004 Didier Loiseau
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if (!defined('WIKINI_VERSION'))
die ('accès direct interdit');
include_once('formatters/hightlighter.class.inc');
$matlab = new Hightlighter();
$matlab->isCaseSensitiv = true;
$matlab->commentLine[] = "(\\%.*(\n|$))";
$matlab->commentStyle = 'color: #228b22;';
$matlab->string[] = "('[^\n]*')";
$matlab->stringStyle = 'color: #b20000;';
$matlab->keywords['Commands']['words'] = array(
'\.\.\.',
'break',
'case',
'catch',
'continue',
'else',
'elseif',
'end',
'for',
'function',
'if',
'return',
'switch',
'try',
'while'
);
$matlab->keywords['Commands']['style'] = 'color: blue;';
echo '<pre>' . $matlab->Analyse($text) . '</pre>';
unset($matlab);
?>