Jump to content

User:Stevage

From mediawiki.org

See en:User:Stevage.

The preprocessor does:

  1. Strip (hooks before/after)
  2. Remove HTML comments
  3. Replace variables
      1. Subst
      2. MSG, MSGNW, RAW
      3. Parser functions
      4. Templates


The parser does:

  1. Strip (hooks before, after)
  2. Internal parse
    1. Noinclude/onlyinclude/includeonly sections
    2. Remove HTML tags
    3. Replace variables
    4. Hooks: Internalparsebeforelinks
    5. Tables
    6. Strip TOC (__NOTOC__, __TOC__)
    7. Strip no gallery (__NOGALLERY__)
    8. do headings
    9. Do dynamic dates
    10. Do quotes ('' and ''')
    11. Replace internal links
    12. Replace external links
    13. Re-replace masked internal links
    14. Do magic links (ISBN, RFC...)
    15. Format headings (__NEWSECTIONLINK__, __FORCETOC__...)
  3. Unstrip general
  4. Fix tags (french spaces, guillemet)
  5. Blocks (lists etc)
  6. Replace link holders
  7. Parser convert
  8. Unstrip no wiki
  9. Extra tags and params
  10. User funcs?
  11. Un strip general
  12. Normalise char references
  13. Tidy + hook

The save parser does:

  1. Convert newlines
  2. Strips
  3. Pass 2
    1. Substs
    2. Strip again? gallery something.
    3. Signatures
    4. Pipe tricks
    5. Trim trailing whitespace
  4. Unstrips

ANTLR grammer for [Image:]

[edit]
grammar image2;

imageinline: LINK_START IMAGE_NAMESPACE COLON imagename ( PIPE imageoption )* LINK_END ;
//imageinline: LINK_START IMAGE_NAMESPACE COLON pagename;
 imagename: pagename  DOT  imageextension;
 imageextension: EXT_JPG | EXT_JPEG | EXT_PNG | EXT_SVG | EXT_GIF | EXT_BMP ;
 imageoption:  imagemodeparameter | imagesizeparameter | imagealignparameter 
                             | imagevalignparameter | imageotherparameter | caption ;

 imagemodeparameter: imagemodemanualthumb | imagemodeautothumb | imagemodeframe | imagemodeframeless;

 imagemodemanualthumb: MW_img_manualthumb imagename;
 imagemodeautothumb: MW_img_thumbnail;
 imagemodeframe: MW_img_frame;
 imagemodeframeless: MW_img_frameless;

/* default settings: */
/* Hmm, user-definable grammar seems to be a bad idea. Assume that the img_manualthumb is always something followed by the name. */
 MW_img_manualthumb: 'thumbnail=' | 'thumb=';
 MW_img_thumbnail: 'thumbnail' | 'thumb';
 MW_img_frame: 'framed' | 'enframed' | 'frame';
 MW_img_frameless: 'frameless';

 imageotherparameter: imageparampage | imageparamupright | imageparamborder;
 imageparampage: MW_img_page ;
 imageparamupright: MW_img_upright ;
// imageparamupright: L_u  L_p  L_r  L_i  L_g  L_h  L_t ;
 imageparamborder: MW_img_border;

/* default settings: */
 MW_img_page: 'page=$1' | 'page $1' ; /*??? (where is this used?);*/
 MW_img_upright: 'upright' (  '='? POSITIVE_INT)?;
 MW_img_border: 'border';


 imagesizeparameter: MW_img_width;
/* default setting: */
 MW_img_width: POSITIVE_INT 'px' ;


 imagealignparameter: imagealignleft | imagealigncenter | imagealignright | imagealignnone;
 imagealignleft: MW_img_left ;
 imagealigncenter: MW_img_center ;
 imagealignright: MW_img_right ;
 imagealignnone: MW_img_none;

/* default settings: */


 imagevalignparameter: imagevalignbaseline | imagevalignsub | imagevalignsuper | imagevaligntop 
                             | imagevaligntexttop | imagevalignmiddle | imagevalignbottom | imagevaligntextbottom;

 imagevalignbaseline: MW_img_baseline ;
 imagevalignsub: MW_img_sub;
 imagevalignsuper: MW_img_super;
 imagevaligntop: MW_img_top;
 imagevaligntexttop: MW_img_text_top;
 imagevalignmiddle: MW_img_middle;
 imagevalignbottom: MW_img_bottom;
 imagevaligntextbottom: MW_img_text_bottom;

/* by default: */
 MW_img_baseline: 'baseline';
 MW_img_sub: 'sub';
 MW_img_super: 'super' | 'sup';
 MW_img_top: 'top';
 MW_img_text_top: 'text-top';
 MW_img_middle: 'middle';
 MW_img_bottom: 'bottom';
 MW_img_text_bottom: 'text-bottom';
 
LINK_START: '[[';
LINK_END: ']]';

IMAGE_NAMESPACE	: 'image';
COLON	:	':';
PIPE	:	'|';

caption: inline_text;
//inline_text: LETTERS;
	
	
//pagename: LETTERS; /*obviously not */
pagename: letters; /*obviously not */

//LETTERS	:	'hello';

inline_text:		lettery (lettery | SPACE | DOT |imageinline)*;

EXT_JPG	:'jpg'	;
lettery	: letters | MW_img_right|MW_img_upright;
	
////TEXT	:(LETTERS | ' ' | '.')+;

POSITIVE_INT:	'0'..'9'+;

EXT_JPEG:'jpeg'	;
EXT_PNG	:'png'	;
EXT_SVG	:'svg'	;
EXT_GIF	:'gif';
EXT_BMP	:'bmp';

DOT	:'.';
SPACE   :' ';	

LETTER	:	('A'..'Z'|'a'..'z');
letters	:	LETTER+;	

 MW_img_left: 'left';
 MW_img_center: 'center' | 'centre';
 MW_img_right: 'right';
 MW_img_none: 'none';