## Please edit system and help pages ONLY in the master wiki!
## For more information, please see MoinMoin:MoinDev/Translation.
##master-page:Unknown-Page
##master-date:Unknown-Date
#acl -All:write Default
#format wiki
#language en
HelpContents > HelpForUsers > HelpOnEditing > HelpOnParsers

= Parsers =

Besides the default MoinMoin wiki markup, different '''parsers''' allow the user to enter content into a page or a page section which is interpreted differently. A MoinMoin wiki mostly will use the default wiki parser, which is described on HelpOnFormatting.

<<TableOfContents>>


== How formats are applied ==

Parsers go through the contents of a page to create a sequence of formatter calls which in sequence create some readable output. MoinMoin will choose the parser for a page using 2 different techniques:
 1. '''[[HelpOnProcessingInstructions#format|FORMAT Processing Instruction]]''' 
 
 A `#FORMAT` processing instruction can be used to tell MoinMoin which parser to use for the whole page content. By default this is the ''wiki'' parser. Example:
 {{{
#FORMAT cplusplus
... some C++ source ...
}}}

 1. '''Code Display Regions''' - see HelpOnFormatting 
 
 With the use of code display regions, a parser can be applied to only a part of a page (this was a processor region in earlier versions of MoinMoin). You specify which parser to call by using a bang path-like construct in the first line. A bang path is a concept known from Unix command line scripts, where they serve the exact same purpose: the first line tells the shell what program to start to process the remaining lines of the script. For example, the code
 {{{{
{{{#!CSV ,
a,b,c
d,e,f
}}}
}}}}
 produces the table:
 {{{#!CSV ,
a,b,c
d,e,f
}}}

(!) Note that there are 2 ways to solve ''nesting problems'' related to `}}}`:
 * Use more than 3 curly braces for beginning / ending of the parser section (what you use must not be contained in the section you are enclosing). E.g.:
 {{{{{
{{{{
{{{
...
}}}
}}}}
}}}}}
 * Use 3 curly braces + some unique string:
 {{{{
{{{asdfghj
{{{
...
}}}
asdfghj}}}
}}}}

For more information on the possible markup, see HelpOnEditing. 

== ParserBase ==

!ParserBase is a parser utility class used to produce colorized source displays. It is easily extended. The HTML Formatter will render such code displays with switchable linenumbers, if the browser supports DOM and !JavaScript.

A !ParserBase colorization parser understands the following arguments to a `#FORMAT` pi or a hashbang line. Just add those arguments after the name of the parser (`#FORMAT python start=10 step=10 numbers=on` or `#!python numbers=off`).

 numbers:: if line numbers should be added. defaults to 'on'. possible values: 'on', 'off' (no line numbers, but javascript to add them), 'disable' (no line numbers at all)
 start:: where to start with numbering. defaults to 1
 step:: increment to the linenumber. defaults to 1

MoinMoin comes with a few examples from which you can go on:

== creole ==

See HelpOnCreoleSyntax.

== python ==

Colorizes python code. It is not derived from Parser``Base, but it allows the same arguments as the !ParserBase parsers.

{{{#!python
def hello():
    print "Hello World!"
}}}

{{{#!python numbers=off
def hello():
    print "Hello World!"
}}}

{{{#!python numbers=disable
def hello():
    print "Hello World!"
}}}

=== cplusplus ===

{{{#!cplusplus
int main(int argc, char **argv) {
  return 0;
}
}}}

=== java ===

{{{#!java
import java.util.Date;
import java.util.Calendar;

public class IntDate
{
  public static Date getDate(String year, String month, String day)
    {
      // Date(int, int, int) has been deprecated, so use Calendar to
      // set the year, month, and day.
      Calendar c = Calendar.getInstance();
      // Convert each argument to int.
      c.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
      return c.getTime();
    }
}
}}}

=== pascal ===

{{{#!pascal
function TRegEx.Match(const s:string):boolean;
var
    l,i : integer;
begin
    result := MatchPos(s,l,i);
end;
}}}

== IRC ==

Puts an IRC log into a table.

{{{#!irc
(23:18) <     jroes> ah
(23:21) -!- gpciceri [~gpciceri@host181-130.pool8248.interbusiness.it] has quit [Read error: 110 (Connection timed out)]
(23:36) < ThomasWal> you could also write a parser or processor
(23:38) <     jroes> i could?
(23:38) <     jroes> would that require modification on the moin end though?
(23:38) <     jroes> i cant change the wiki myself :x
}}}

The format parsed is the log format of IRSSI, a popular console IRC client, but it should also match the log format of quite some other IRC clients.

<<Anchor(csvparser)>>
== CSV ==

The CSV parser works on so-called ''comma separated values'', though the comma is now usually and by default a semicolon. 
The first line is considered to contain column titles that are rendered in '''bold''', so when you don't want table headers, leave the first line empty.

The bang path can contain the following arguments:
 * `delimiter` or `separator`: `delimiter=,` will set the delimiter to a comma
 * `quotechar`: `quotechar="` will allow quoting values with a double-quote
 * `show`: comma-separated list of columns to show only
 * `hide`: comma-separated list of columns to hide
 * `autofilter`: comma-separated list of columns to add auto-filters on
 * `name`: name of the dataset
 * `link`: comma-separated list of columns consisting of `http://example.com/link description text` rather than just text
 * `static_cols`, `static_vals`: columns (and respective values) added to each record
 * `-N` (where N is a number): hide column N (useful when column names are omitted)

The parser also supports the old, deprecated syntax for the bang path.

Example tables (please see the raw text of this page for the markup used): 

!MoinMoin 1.3 - clipping of the patch history:
{{{#!CSV delimiter=, -4

patch-366,make _normalize_text public method,Nir Soffer,2004-11-30 19:11:51 GMT
patch-367,fixed failing test wikiutil: good system page names,Nir Soffer,2004-11-30 19:15:52 GMT
patch-368,Fixed DeprecationWarning in RandomPage.py and an unused import in twistedmoin.py,Alexander Schremmer,2004-11-30 22:58:44 GMT
patch-369,remove duplicate code in formatter.base,Thomas Waldmann,2004-12-01 00:14:21 GMT
patch-370,fixed long int in mig3,Thomas Waldmann,2004-12-01 01:51:50 GMT
patch-371,fixed unicode error on eventlog,Nir Soffer,2004-12-01 14:46:29 GMT
patch-372,fixed util.web.makeQueryString and Page.url,Nir Soffer,2004-12-01 15:48:55 GMT
patch-373,fixed again non ascii http_referer,Nir Soffer,2004-12-01 18:55:28 GMT
patch-374,CSV.py supports different separators now,Alexander Schremmer,2004-12-01 23:46:17 GMT
patch-375,improved searchform behavior on Mozilla/Firefox,Nir Soffer,2004-12-02 04:57:06 GMT
patch-376,More correct script for actions menu init,Nir Soffer,2004-12-02 05:07:58 GMT
}}}

MoinMoin Version History:
{{{#!CSV hide=HIDDEN!
Version;Date;HIDDEN!
0.11;2002-03-11;Revision 1.151
0.10;2001-10-28;Revision 1.134
0.9;2001-05-07;
0.8;2001-01-23;
0.7;2000-12-06;
0.6;2000-12-04;
0.5;2000-11-17;
0.4;2000-11-01;
0.3;2000-10-25;
0.2;2000-08-26;
0.1;2000-07-29;
}}}

== reStructuredText ==

See /ReStructuredText

== XML/XSLT/DocBook ==

See HelpOnXmlPages.

== Additional Parsers ==

For many more parsers and installation instructions, see MoinMoin:ParserMarket
