Wikini

ColorationSyntaxiqueCSS

PagePrincipale :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes ec2-52-14-126-74.us-east-2.compute.amazonaws.com

Nom de la contribution : ColorationSyntaxiqueCSS
Description : Coloration syntaxique du langage CSS.
Type de contribution : coloration syntaxique
Fonctionne avec : WikiNi 0.4.3 et ultérieur.
Intégration technique : placer le fichier coloration_css.php dans le répertoire formatters/
Mainteneur : VirtualDust?
Licence : GPL
Dernière version : 0.1.1
Dernière livraison : 30-10-2005
Accès au code et mise en oeuvre : ColorationSyntaxiqueCSS.
Démonstration :
Intégration au projet WikiNi :
Bugs: signaler ici les bugs

Description Détaillée:
Il s'agit d'une coloration syntaxique du langage CSS basée sur la spécification version 2.1 du W3C. Si j'ai oublié quelque chose, n'hésitez pas. Tous mes tests ont été concluant jusqu'à présent.
La coloration utilisée n'est basée que sur mes goûts personnels. Libre à vous d'en changer.
Ce colorateur est normalement compatible WikiNi 0.4.3 et ultérieur en prenant en compte le renommage de la classe Highlighter et du fichier qui l'implémente à la version 0.5.0.

coloration_css.php (téléchargeable ICI)
<?php
/*
* coloration_css.php
* v0.1.0
*
* Colorateur pour Cascading Style Sheets (CSS)
*
* copyright Raphaël BOIS 2005 mailto: vdust (at) free [point] fr
*
* Licence : la meme que wikini (voir le fichier LICENCE).
* Vous êtes libre d'utiliser et de modifier ce code à condition de laisser le copyright
* d'origine. Vous pouvez  bien sur vous ajouter à la liste des auteurs.
*
* Installation : copier le fichier dans le repertoire "formatters" de WikiNi
*/

//Teste la version de wikini.
if(substr($wakkaConfig["wikini_version"],0,3) === "0.4")
{
  
//La classe Hightlighter a été renommée à la version 0.5.0 en Highlighter
  //ainsi que le fichier qui déclare cette classe.
  
include_once('formatters/hightlighter.class.inc');
  
/* Création instance pour langage CSS */
  
$C = new Hightlighter();
}
else
{
  include_once(
'formatters/highlighter.class.inc.php');
  
/* Création instance pour langage CSS */
  
$C = new Highlighter();  
}


$C->isCaseSensitiv true;

/* Définition des commentaires */

$C->comment[] = '(/\*(.*)\*/)';
$C->commentStyle "color: #509080;";


/* Définition des chaines de caractères */
$C->string[] = '("((\\\")|[^"])*")';
$C->stringStyle "color: blue";

/* Définition des nombres - dimensions - couleurs */
$C->number[] = '(\b(\.\d|\d+(\.\d+|\.)|\d+)(em|ex|px|in|cm|mm|pt|pc|)\b)';
$C->number[] = '(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3}))';
$C->numberStyle 'color: #606060';

/* Définition des directives de compilation */

$C->directive = array('@import''@media''@charset''@page''!important');
$C->directiveStyle 'font-weight:bold; font-style:italic;';


/* Propriétés */
$C->keywords['properties']['words'] = array(
   
'azimuth',
   
'background-(attachement|color|image|position|repeat)''background',
   
'border-(collapse|color|spacing|style|width|top|right|bottom|left)',
   
'border-(top|right|bottom|left)-(color|style|width)''border',
   
'bottom''caption-side''clear''clip''color''content',
   
'counter-(increment|reset)''cue-(after|before)''cue',
   
'cursor''direction''display''elevation''empty-cells',
   
'float','font-(family|size|style|variant|weight)','font',
   
'height''left''letter-spacing''line-height',
   
'list-style-(image|position|type)''list-style',
   
'margin-(left|right|top|bottom)''margin''(max|min)-(height|width)',
   
'orphans''outline-(color|style|width)''outline''overflow',
   
'padding-(top|right|bottom|left)''padding',
   
'page-break-(after|before|inside)''pause-(after|before)''pause',
   
'pitch-range''pitch''play-during''position''quotes''richness'
   
'right','speak-(header|numeral|punctuation)','speak''speech-rate',
   
'stress''table-layout''text-(align|decoration|indent|transform)'
   
'top''unicode-bidi''vertical-align''visibility''voice-family'
   
'volume''white-space''widows''width''word-spacing''z-index'
);
$C->keywords['properties']['style'] = 'font-weight: bold; color: #7f0055;';


/* mots-clés pour les valeurs de propriétés */

/* Etant donné que certains mots clés sont répétés pour une question de lisibilité,
 * il est indispensable qu'ils soient colorés de la même manière, le context de leur
 * utilisation n'étant pas (actuellement) interprétable par le colorateur.
 * De plus, lorsqu'il n'y a pas de nouveau mot-clés pour une propriété donnée,
 * aucune nouvelle entrée n'est ajoutée.
 */
$valueStyle 'color:green'//couleur à utiliser pour tous les mot-clés

$C->keywords['other values']['words'] = array('inherit''none''auto''both''normal''default');
$C->keywords['other values']['style'] = $valueStyle;

$C->keywords['azimuth values']['words'] = array(
   
'(right|left)-side''(far|center)-(left|right)',
   
'left''center''right',
   
'behind''leftwards''rightwards');
$C->keywords['azimuth values']['style'] = $valueStyle;

$C->keywords['background values']['words'] = array(
   
'scroll''fixed'//-attachement
   
'repeat''repeat-(x|y)''no-repeat' //-repeat
);
$C->keywords['background values']['style'] = $valueStyle;

$C->keywords['position values']['words'] = array(
   
'left','center','right','top','bottom',   //background
   
'static''relative''absolute''fixed' //position
);
$C->keywords['position values']['style'] = $valueStyle;

$C->keywords['border values']['words'] = array(
   
'collapse','separate'//-collapse
   
'hidden','dotted','dashed','solid','double','groove','ridge','inset','outset'//-style
   
'thin''medium''thick'//-width
);
$C->keywords['border values']['style'] = $valueStyle;

$C->keywords['content values']['words'] = array('(open|close|no-open|no-close)-quote');
$C->keywords['content values']['style'] = $valueStyle;

$C->keywords['cursor values']['words'] = array(
   
'crosshair','pointer','move','(e|ne|nw|n|se|sw|s|w)-resize',
   
'text''wait''help''progress'   
);
$C->keywords['cursor values']['style'] = $valueStyle;

$C->keywords['color values']['words'] = array(
   
'aqua''black''blue''fuchsia''gray''green''lime''maroon',
   
'navy''olive''orange''purple''red''silver''teal''white',
     
'yellow''transparent'
);
$C->keywords['color values']['style'] = 'font-style: italic'//choix personnel de distinguer les couleurs des autres mot-clés

$C->keywords['direction values']['words'] = array('ltr''rtl');
$C->keywords['direction values']['style'] = $valueStyle;

$C->keywords['display values']['words'] = array(
   
'inline''block''list-item''run-in''inline-(block|table)''table',
   
'table-((row|header|footer|column)-group|row|column|cell|caption)'
);
$C->keywords['display values']['style'] = $valueStyle;

$C->keywords['elevation values']['words'] = array(
   
'below''level''above''higher''lower'
);
$C->keywords['elevation values']['style'] = $valueStyle;

$C->keywords['empty-cells values']['words'] = array('show''hide');
$C->keywords['empty-cells values']['style'] = $valueStyle;

$C->keywords['font values']['words'] = array(
   
'serif''sans-serif''cursive''fantasy''monospace'//-family
   
'(xx|x)-(small|large)''small','medium','large''larger''smaller'//-size
   
'italic','oblique'//-style
   
'small-caps'//-variant
   
'bold''bolder''lighter'//-weight
   
'caption','icon','menu','message-box','small-caption''status-bar' //font
);
$C->keywords['font values']['style'] = $valueStyle;

$C->keywords['list-style values']['words'] = array(
   
'inside''outside'//-position 
   
'disc''circle''square''decimal''decimal-leading-zero'//-type
   
'(lower|upper)-(roman|latin|alpha)','lower-greek','armenian','georgian' //...
);
$C->keywords['list-style values']['style'] = $valueStyle;

$C->keywords['page-break values']['words'] = array(
   
'always''avoid''left''right'
);
$C->keywords['page-break values']['style'] = $valueStyle;

$C->keywords['pitch values']['words'] = array(
   
'w-low''low''medium''high''x-high'
);
$C->keywords['pitch values']['style'] = $valueStyle;

$C->keywords['play-during values']['words'] = array('mix''repeat');
$C->keywords['play-during values']['style'] = $valueStyle;

$C->keywords['speak values']['words'] = array(
    
'once''always',       //-header
    
'digits''continuous'//-numeral
    
'code',                 //-punctuation
    
'spell-out',            //speak
);
$C->keywords['speak values']['style'] = $valueStyle;

$C->keywords['speech values']['words'] = array(
   
'x-slow''slow''medium''fast''xfast''faster''slower');
$C->keywords['speech values']['style'] = $valueStyle;

$C->keywords['text values']['words'] = array(
   
'left''right''center''justify',             //-align
   
'underline''overline''line-through''blink'//-decoration
   
'capitalize''uppercase''lowercase'            //-transform
);
$C->keywords['text values']['style'] = $valueStyle;

$C->keywords['unicode-bidi values']['words'] = array('embed''bidi-override');
$C->keywords['unicode-bidi values']['style'] = $valueStyle;

$C->keywords['vertical-align values']['words'] = array(
   
'baseline''sub''super''top''text-top''middle''bottom''text-bottom');
$C->keywords['vertical-align values']['style'] = $valueStyle;

$C->keywords['visibility values']['words'] = array('visible''hidden''collapse');
$C->keywords['visibility values']['style'] = $valueStyle;

$C->keywords['voice-family values']['words'] = array('male''female''child');
$C->keywords['voice-family values']['style'] = $valueStyle;

$C->keywords['volume values']['words'] = array(
   
'silent''x-(soft|loud)''soft''medium''loud');
$C->keywords['volume values']['style'] = $valueStyle;

$C->keywords['white-space values']['words'] = array(
   
'normal''pre''nowrap''pre-(wrap|line)');
$C->keywords['white-space values']['style'] = $valueStyle;

/* FIN mots-clés pour les valeurs de propriétés */


/*Noms de "functions"*/
$C->keywords['functions']['words'] = array('url''attr''rect''counter');
$C->keywords['functions']['style'] = 'color:blue;';

/* mots clés apparaissant après un identifiant de classe*/
$C->keywords['other keywords']['words'] = array('before''after''hover');
$C->keywords['other keywords']['style'] = 'font-weight:bold;';

/* Définition des symboles */
$C->symboles = array('(',')''[',']','{','}','>','+','.'':''!''@'';');
$C->symbolesStyle 'font-weight: normal';

/* Définition du reste... */
$C->identifier =  array('[_A-Za-z]{1}[_A-Za-z0-9]*');
$C->identStyle '';


echo 
"<pre>".$C->Analyse($text)."</pre>\n";
unset(
$C);
?>

Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]