Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Language Definition v2.0 Reference: GtkSourceView 3 Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GtkSourceView 3 Reference Manual">
<link rel="up" href="pt03.html" title="Part III. Syntax highlighting reference">
<link rel="prev" href="lang-tutorial.html" title="Language Definition v2.0 Tutorial">
<link rel="next" href="style-reference.html" title="Style Scheme Definition Reference">
<meta name="generator" content="GTK-Doc V1.28.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="pt03.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="lang-tutorial.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="style-reference.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="lang-reference"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Language Definition v2.0 Reference</span></h2>
<p>Language Definition v2.0 Reference — 
Reference to the GtkSourceView language definition file format
</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="id-1.4.3.3"></a><h2>Overview</h2>
<div class="note"><p>
    The version 2 here refers to the language definition file format,
    not to the version of GtkSourceView. This reference is suitable
    for GtkSourceView 2 and 3.
  </p></div>
<p>
This is an overview of the Language Definition XML format, describing the
meaning and usage of every element and attribute.  The formal definition is
stored in the RelaxNG schema file <code class="filename">language2.rng</code> which
should be installed on your system in the directory
<code class="filename">${PREFIX}/share/gtksourceview-3.0/</code> (where
<code class="filename">${PREFIX}</code> can be <code class="filename">/usr/</code> or
<code class="filename">/usr/local/</code> if you have installed from source.
</p>
<p>
The preinstalled language files are located in
<code class="filename">${PREFIX}/share/gtksourceview-3.0/language-specs/</code>. Custom
user languages are usually placed in
<code class="filename">~/.local/share/gtksourceview-3.0/language-specs/</code>. Note:
replace 3 with 2 in the path for GtkSourceView version 2.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.4"></a><h2>Some advices</h2>
<p>
The easiest way to start a new language definition is to copy a preinstalled
language definition from a language that has similar constructs as the one you
want to write a specification for. You can copy and rename a file from the
systems directory to the local user one (create the directory if it doesn't
exist yet) and edit the file accordingly.
</p>
<p>
The important thing you need to change are the <code class="code">id</code> and
<code class="code">name</code> of the language and the metadata properties
<code class="code">mimetypes</code> and <code class="code">globs</code> in the language spec. These
should resemble your new language. It might be that your files do not have an
appropriate mimetype associated yet. You can either in that case leave it
empty, or add a new mimetype (see below).
</p>
<p>
If for some reason your language spec doesn't show up in an application like
gedit, it might be a good idea to start the application from a terminal window
and see if any errors/warnings appear for your language file. This usually
gives good clues what's wrong with the specification. Note that you need to
restart the application to take into account changes in a language definition
file.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.5"></a><h2>Conventions</h2>
<p>
It is better to follow the following conventions, especially if you want to
contribute upstream, and get your language definition file included in
GtkSourceView.
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>
      Indentation: 2 spaces.
    </p></li>
<li class="listitem"><p>
      Have the main context at the bottom.
    </p></li>
<li class="listitem"><p>
      Use references to def.lang.
    </p></li>
<li class="listitem"><p>
      Add an example in tests/syntax-highlighting/.
    </p></li>
<li class="listitem"><p>
      LGPL v2.1+ license (copy/paste the license header from c.lang, for
      example).
    </p></li>
<li class="listitem"><p>
      Add the e-mail address of the language definition file author(s).
    </p></li>
<li class="listitem"><p>
      Refer to the HACKING file for submitting your language definition
      file upstream. If the file is not included upstream, you can also
      add the language definition file to the GtkSourceView wiki, so
      users can easily find it.
    </p></li>
</ul></div>
</div>
<div class="refsect1">
<a name="id-1.4.3.6"></a><h2>Tag <code class="code">&lt;language&gt;</code>
</h2>
<p>
The root element for Language Definition files.
</p>
<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;metadata&gt;</code> (optional), <code class="code">&lt;styles&gt;</code> (optional), <code class="code">&lt;default-regex-options&gt;</code> (optional), <code class="code">&lt;keyword-char-class&gt;</code> (optional), <code class="code">&lt;definitions&gt;</code> (mandatory)</span>.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">id</code> (mandatory)</span></p></td>
<td><p>
Identifier for the description. This is used for
external references and must be unique among language descriptions. It can
contain a string of letters, digits, hyphens ("<code class="code">-</code>") and
underscores ("<code class="code">_</code>").
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">name</code> (mandatory)</span></p></td>
<td><p>
The translatable name of the language presented to the user.
It can be marked for translation putting an underscore before the attribute
name (see the gettext documentation).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">version</code> (mandatory)</span></p></td>
<td><p>
The version of the XML format (currently "2.0").
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">section</code> (optional)</span></p></td>
<td><p>
The translatable category in which the language has to be grouped when
presented to the user. It can be marked for translation putting
an underscore before the attribute name. Currently used categories in
GtkSourceView are "Source", "Script",  "Markup" and "Other", but
it is possible to use arbitrary categories (while usually discouraged).
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">hidden</code> (optional)</span></p></td>
<td><p>
It's a hint that the language should be "hidden" from user. For instance,
def.lang has this flag, and a text editor should not present "default" as
a syntax highlighting choice.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="refsect1">
<a name="id-1.4.3.7"></a><h2>Tag <code class="code">&lt;metadata&gt;</code>
</h2>
<p>
Contains optional metadata about the language definition.
</p>
<p>
Recognized elements are (all optional):
</p>
<dt><span class="term"><code class="code">mimetypes</code></span></dt>
<dd><p>
The semicolon-separated list of mimetypes associated to the language. See the
<a class="ulink" href="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/" target="_top">shared-mime-info</a>
freedesktop.org specification. A language definition file shipped by
GtkSourceView needs to have a mimetype defined in the shared-mime-info
database. If the language definition file is not shipped by GtkSourceView, you
can also create the mimetype locally, usually in
<code class="filename">~/.local/share/mime/packages/</code>.
</p></dd>
<dt><span class="term"><code class="code">globs</code></span></dt>
<dd><p>
The semicolon-separated list of globs associated to the language.
</p></dd>
<dt><span class="term"><code class="code">line-comment-start</code></span></dt>
<dd><p>
String used to create single-line comment in files of this type, e.g.
"#" in shell scripts.
It may be used in an editor to implement Comment/Uncomment functionality.
</p></dd>
<dt><span class="term"><code class="code">block-comment-start</code></span></dt>
<dd><p>
String used to start block comment in files of this type, e.g. "/*" in C
files.
</p></dd>
<dt><span class="term"><code class="code">block-comment-end</code></span></dt>
<dd><p>
String used to end block comment in files of this type, e.g. "*/" in C
files.
</p></dd>
</div>
<div class="refsect1">
<a name="id-1.4.3.8"></a><h2>Tag <code class="code">&lt;styles&gt;</code>
</h2>
<p>
Contains the definitions of every style used in the current language and
their association with predefined styles in GtkSourceView.
</p>
<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;style&gt;</code> (one or more)</span>.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.9"></a><h2>Tag <code class="code">&lt;style&gt;</code>
</h2>
<p>
Defines a style, associating its id with a user visible translatable
name and a default style.
</p>
<p>
Contained elements: none.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">id</code> (mandatory)</span></p></td>
<td><p>
Identifier for the style. This is used in the current language
to refer to this style and must be unique for the current document.
It can contain a string of letters, digits,
hyphens ("<code class="code">-</code>") and underscores ("<code class="code">_</code>").
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">name</code> (mandatory)</span></p></td>
<td><p>
The user visible translatable name for the style. It has to be preceded
with a underscore ("<code class="code">_</code>") to be marked for translation.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">map-to</code> (optional)</span></p></td>
<td><p>
Used to map the style with a default style, to use colors and
font properties defined for those default styles.
The id of the default style has to be preceded with the id of the
language where it is defined, separated with a semicolon ":".
When omitted the style is not considered derived from any style and will
not be highlighted until the user specifies a color scheme for this
style.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="refsect1">
<a name="id-1.4.3.10"></a><h2>Tag <code class="code">&lt;keyword-char-class&gt;</code>
</h2>
<p>
Contains a regex character class used to redefine the customizable
word boundary delimiters "\%[" and "\%]". This class is the set of character
that can be commonly found in a keyword.
If the element is omitted the two delimiters default to "\b".
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.11"></a><h2>Tag <code class="code">&lt;default-regex-options&gt;</code>
</h2>
<p>
Used to set global options for how regular expressions are processed.
</p>
<p>
Contained elements: none.
</p>
<div class="variablelist">
<p class="title"><b>Attributes</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">case-sensitive</code> (optional)</span></p></td>
<td><p>Set to <code class="code">false</code> to make regular expressions
ignore case.
Defaults to <code class="code">true</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">extended</code> (optional)</span></p></td>
<td><p>Setting this to <code class="code">true</code> makes the regular
expression engine ignore spaces and comments. These comments start with
"<code class="code">#</code>" and continue to the end of the line.
Defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">dupnames</code> (optional)</span></p></td>
<td><p>Setting this to true allows one to repeat an identifier
for capturing parentheses.  This is useful for some patterns that you
know only one instance of a named subpattern can ever be matched.
Defaults to <code class="code">false</code>.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="refsect1">
<a name="id-1.4.3.12"></a><h2>Tag <code class="code">&lt;definitions&gt;</code>
</h2>
<p>
The element containing the real description of the syntax to be
highlighted. It contains one or more <code class="code">&lt;context&gt;</code> element and an
arbitrary number of <code class="code">&lt;define-regex&gt;</code> elements, interleaved.
It has no attributes.
Every contained element must have its <code class="code">id</code> attribute set to an
identifier unique for the document. Exactly one of the contained
<code class="code">&lt;context&gt;</code> element must have
the <code class="code">id</code> attribute set to the <code class="code">id</code> of the
<code class="code">&lt;language&gt;</code> root element,
representing the initial context for the highlighting, the one the engine
enters at the beginning of the highlighted file.
</p>
<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;context&gt;</code> (one or more), <code class="code">&lt;define-regex&gt;</code> (zero or more)</span>.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.13"></a><h2>Tag <code class="code">&lt;define-regex&gt;</code>
</h2>
<p>
The syntax highlighting engine of GtkSourceView uses
<span class="type">GRegex</span>,
which uses the PCRE library. See the
<a class="ulink" href="https://developer.gnome.org/glib/stable/glib-regex-syntax.html" target="_top">Regular expression syntax</a>
page in the GLib reference manual.
</p>
<p>
The <code class="code">&lt;define-regex&gt;</code> tag defines a regular expression that can
be reused inside other regular expression, to avoid replicating common portions.
Those regular expressions are in the form <code class="code">/regex/options</code>.  If there
are no options to be specified and you don't need to match the spaces at the
start and at the end of the regular expression, you can omit the slashes,
putting here only <code class="code">regex</code>.  The possible options are those specified
above in the description of the <code class="code">&lt;default-regex-options&gt;</code>
element. To disable a group of options, instead, you have to prepend an hyphen
<code class="code">-</code> to them.  In GtkSourceView are also available some extensions to
the standard Perl style regular expressions:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>
<code class="code">\%[</code> and <code class="code">\%]</code> are custom word boundaries, which can
be redefined with the <code class="code">&lt;keyword-char-class&gt;</code> (in contrast with
<code class="code">\b</code>);
</p></li>
<li class="listitem"><p>
<code class="code">\%{id}</code> will include the regular expression defined in another
<code class="code">&lt;define-regex&gt;</code> element with the specified id.
</p></li>
</ul></div>
<p>
It is allowed to use any of the attributes from
<code class="code">&lt;default-regex-options&gt;</code> as attributes of this tag.
</p>
<p>
Contained elements: none.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="code">id</code> (mandatory)</span></p></td>
<td><p>
Identifier for the regular expression. This is used
for the inclusion of the defined regular expression and must be unique
for the current document. It can contain a string of letters, digits,
hyphens ("<code class="code">-</code>") and underscores ("<code class="code">_</code>").
</p></td>
</tr></tbody>
</table>
</div>
</div>
<div class="refsect1">
<a name="id-1.4.3.14"></a><h2>Tag <code class="code">&lt;context&gt;</code>
</h2>
<p>
This is the most important element when describing the syntax: the file to
be highlighted is partitioned in contexts representing the portions to be
colored differently. Contexts can also contain other contexts.
There are different kind of context elements: simple contexts, container
contexts, sub-pattern contexts, reference contexts and keyword contexts.
</p>
<p>
Context classes can be enabled or disabled for some contexts, with the
<code class="code">class</code> and <code class="code">class-disabled</code> attributes. You can create
your own context classes in custom language definition files. Here are the
default context classes:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>
      <span class="emphasis"><em>comment</em></span>: the context delimits a comment;
    </p></li>
<li class="listitem"><p>
      <span class="emphasis"><em>no-spell-check</em></span>: the context's content should
      not be spell checked;
    </p></li>
<li class="listitem"><p>
      <span class="emphasis"><em>path</em></span>: the context delimits a path to a file;
    </p></li>
<li class="listitem"><p>
      <span class="emphasis"><em>string</em></span>: the context delimits a string.
    </p></li>
</ul></div>
<div class="refsect2">
<a name="id-1.4.3.14.5"></a><h3>Simple contexts</h3>
They contain a mandatory <code class="code">&lt;match&gt;</code> element and an optional
<code class="code">&lt;include&gt;</code> element. The context will span over the strings
matched by the regular expression contained in the <code class="code">&lt;match&gt;</code>
element. In the <code class="code">&lt;include&gt;</code> element you
can only put sub-pattern contexts.

<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;match&gt;</code> (mandatory), <code class="code">&lt;include&gt;</code> (optional)</span>.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">id</code> (optional)</span></p></td>
<td><p>
A unique identifier for the context, used in references to the context. It
can contain a string of letters, digits, hyphens ("<code class="code">-</code>") and
underscores ("<code class="code">_</code>").
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">style-ref</code> (optional)</span></p></td>
<td><p>
Highlighting style for this context. Value of this attribute
may be id of a style defined in current lang file, or id of a style
defined in other files prefixed with corresponding language id,
e.g. "def:comment".
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">extend-parent</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context has higher
priority than the end of its parent. If not specified it defaults to
<code class="code">true</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">end-parent</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context terminates parent context.
If not specified it defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">first-line-only</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context can occur only
on the first line of buffer. If not specified it defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">once-only</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context can occur only
once in its parent. If not specified it defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">class</code> (optional)</span></p></td>
<td><p>
A space-separated list of context classes to enable.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">class-disabled</code> (optional)</span></p></td>
<td><p>
A space-separated list of context classes to disable.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<div class="refsect2">
<a name="id-1.4.3.14.6"></a><h3>Container contexts</h3>
They contain a <code class="code">&lt;start&gt;</code> element and an optional
<code class="code">&lt;end&gt;</code>. They respectively contain the regular
expression that makes the engine enter in the context and the terminating one.
In the optional <code class="code">&lt;include&gt;</code> element you can put contained
contexts of every type (simple, container, sub-pattern or reference).
If the <code class="code">&lt;start&gt;</code> element is omitted, then the
<code class="code">id</code> attribute and the <code class="code">&lt;include&gt;</code> become
mandatory (the context can only be used as a container to include
its children).

<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;start&gt;</code> (optional), <code class="code">&lt;end&gt;</code> (optional), <code class="code">&lt;include&gt;</code> (optional)</span>.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">id</code> (mandatory only if <code class="code">&lt;start&gt;</code> not present)</span></p></td>
<td><p>
A unique identifier for the context, used in references to the context. It
can contain a string of letters, digits, hyphens ("<code class="code">-</code>") and
underscores ("<code class="code">_</code>").
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">style-ref</code> (optional)</span></p></td>
<td><p>
Highlighting style for this context. Value of this attribute
may be id of a style defined in current lang file, or id of a style
defined in other files prefixed with corresponding language id,
e.g. "def:comment".
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">style-inside</code> (optional)</span></p></td>
<td><p>
If this attribute is "true", then the highlighting style will
be applied to the area between start and end matches; otherwise
whole context will be highlighted.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">extend-parent</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context has a higher
priority than the end of its parent. If not specified it defaults to
<code class="code">true</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">end-at-line-end</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context must be forced
to end at the end of the line. If not specified it defaults to
<code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">end-parent</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context terminates parent context
when it ends.
If not specified it defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">first-line-only</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context can start only
on the first line of buffer. If not specified it defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">once-only</code> (optional)</span></p></td>
<td><p>
A boolean value telling the engine whether the context can occur only
once in its parent. For a container context, it means that
<span class="emphasis"><em>each</em></span> included context can occur once.
If not specified it defaults to <code class="code">false</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">class</code> (optional)</span></p></td>
<td><p>
A space-separated list of context classes to enable.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">class-disabled</code> (optional)</span></p></td>
<td><p>
A space-separated list of context classes to disable.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<div class="refsect2">
<a name="id-1.4.3.14.7"></a><h3>Sub-pattern contexts</h3>
<p>
They refer to a group in a regular expression of the parent context, so it
is possible to highlight differently only a portion of the matched regular
expression.
</p>
<p>
Contained elements: none.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">id</code> (optional)</span></p></td>
<td><p>
A unique identifier for the context. It can contain a string of letters,
digits, hyphens ("<code class="code">-</code>") and underscores ("<code class="code">_</code>").
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">sub-pattern</code> (mandatory)</span></p></td>
<td><p>
The sub-pattern to which we refer. "0" means the whole expression, "1" the
first group, "2" the second one, etc. If named sub-patterns are used you can
also use the name.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">where</code> (mandatory only in container contexts)</span></p></td>
<td><p>
Can be "<code class="code">start</code>" or "<code class="code">end</code>". It has to be used
only if the parent is a container context to specify whether the
sub-pattern is in the regular
expression of the <code class="code">&lt;start&gt;</code> or the <code class="code">&lt;end&gt;</code>
element. In simple contexts it must be omitted.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">class</code> (optional)</span></p></td>
<td><p>
A space-separated list of context classes to enable.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">class-disabled</code> (optional)</span></p></td>
<td><p>
A space-separated list of context classes to disable.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<div class="refsect2">
<a name="id-1.4.3.14.8"></a><h3>Reference contexts</h3>
<p>
Used to include a previously defined context.
</p>
<p>
Contained elements: none.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">ref</code> (mandatory)</span></p></td>
<td><p>
The id of the context to be included. A colon followed by an asterisk
("<code class="code">:*</code>") at the end of the id means that the parent should include
every children of the specified context, instead of the context itself.
Prepending the id of another language to the id of the context (separated
with a semicolon ":") is possible to include contexts defined inside such
external language.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">style-ref</code> (optional)</span></p></td>
<td><p>
Style in included context may be overridden by using this attribute.
Its value is id of the style to be used instead of style specified
in the referenced context.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">ignore-style</code> (optional)</span></p></td>
<td><p>
If this attribute is "true" then the referenced context will not
be highlighted. It does not affect child contexts and their styles.
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">original</code> (optional)</span></p></td>
<td><p>
If this attribute is "true", it references the original context, if it
has been replaced with the <code class="code">&lt;replace&gt;</code> tag.
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<div class="refsect2">
<a name="id-1.4.3.14.9"></a><h3>Keyword contexts</h3>
<p>
They contain a list of <code class="code">&lt;keyword&gt;</code> and matches every keyword
listed. You can also put a <code class="code">&lt;prefix&gt;</code> and/or a
<code class="code">&lt;suffix&gt;</code> common to every keyword.
</p>
<p>
Note that keywords are matched in the order they are listed, so if you
have both a keyword "foo" and a keyword "foobar", you should always list
foobar before foo, or it will never be matched.
</p>
<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;prefix&gt;</code> (optional), <code class="code">&lt;suffix&gt;</code> (optional), <code class="code">&lt;keyword&gt;</code> (one or more)</span>.
</p>
<p>
The attributes are the same used in simple contexts. If the
<code class="code">once-only</code> attribute is <code class="code">true</code>, it means that
<span class="emphasis"><em>each</em></span> keyword can occur once.
</p>
</div>
</div>
<div class="refsect1">
<a name="id-1.4.3.15"></a><h2>Tag <code class="code">&lt;include&gt;</code>
</h2>
<p>
Contains the list of context contained in the current
<code class="code">&lt;context&gt;</code>.
</p>
<p>
Contained elements:
<span class="simplelist"><code class="code">&lt;context&gt;</code> (one or more), <code class="code">&lt;define-regex&gt;</code> (zero or more)</span>.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.16"></a><h2>Tag <code class="code">&lt;match&gt;</code>
</h2>
<p>
Contains the regular expression for the current simple context.
The expression is in the same form used in
<code class="code">&lt;define-regex&gt;</code> elements.
It is allowed to use any of the attributes from
<code class="code">&lt;default-regex-options&gt;</code> as attributes of this tag.
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.17"></a><h2>Tag <code class="code">&lt;start&gt;</code>
</h2>
<p>
Contains the starting regular expression for the current container context.
The expression is in the same form used in <code class="code">&lt;define-regex&gt;</code>
elements.
It is allowed to use any of the attributes from
<code class="code">&lt;default-regex-options&gt;</code> as attributes of this tag.
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.18"></a><h2>Tag <code class="code">&lt;end&gt;</code>
</h2>
<p>
Contains the terminating regular expression for the current container
context. The expression is in the same form used in <code class="code">&lt;define-regex&gt;</code>
elements, with an extension: <code class="code">\%{sub-pattern@start}</code> will be
substituted with the string matched in the corresponding sub-pattern
(can be a number or a name if named sub-patterns are used) in the
preceding <code class="code">&lt;start&gt;</code> element. For instance you could
implement shell-style here-documents with this code:
</p>
<pre class="programlisting">
&lt;context id="here-doc"&gt;
    &lt;start&gt;&amp;lt;&amp;lt;\s*(\S+)$&lt;/start&gt;
    &lt;end&gt;^\%{1@start}$&lt;/end&gt;
&lt;/context&gt;
</pre>
<p>
It is also possible to use any of the attributes from
<code class="code">&lt;default-regex-options&gt;</code> as attributes of this tag.
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.19"></a><h2>Tag <code class="code">&lt;keyword&gt;</code>
</h2>
<p>
Contains a keyword to be matched by the current context. The keyword is a
regular expression in the form used in <code class="code">&lt;define-regex&gt;</code>.
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.20"></a><h2>Tag <code class="code">&lt;prefix&gt;</code>
</h2>
<p>
Contains a prefix common to all of the following keywords in the current
context. The prefix is a regular expression in the form used in
<code class="code">&lt;define-regex&gt;</code>. If not specified it defaults to
<code class="code">\%[</code>
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.21"></a><h2>Tag <code class="code">&lt;suffix&gt;</code>
</h2>
<p>
Contains a suffix common to all of the following keywords in the current
context. The suffix is a regular expression in the form used in
<code class="code">&lt;define-regex&gt;</code>. If not specified it defaults to
<code class="code">\%]</code>
</p>
<p>
Contained elements: none.
</p>
</div>
<div class="refsect1">
<a name="id-1.4.3.22"></a><h2>Tag <code class="code">&lt;replace&gt;</code>
</h2>
<p>
The replace tag allows you to change one context so it functions as
another context.  For example, in the <code class="code">html.lang</code> definition,
there are a few references to a null context with id
"<code class="code">embedded-lang-hook</code>".  In <code class="code">php.lang</code>, that context is
replaced like this: <code class="code">&lt;replace id="html:embedded-lang-hook"
ref="php-block"&gt;</code>, so that php blocks are recognized within the
<code class="code">html:html</code> context at the points where the
<code class="code">embedded-lang-hook</code> context appears.
</p>
<p>
Contained elements: none.
</p>
<div class="variablelist">
<p class="title"><b>Attributes:</b></p>
<table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="code">id</code> (mandatory)</span></p></td>
<td><p>
The id of the context to replace. Ex: <code class="code">id="html:embedded-lang-hook"</code>
</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="code">ref</code> (mandatory)</span></p></td>
<td><p>
The id of the context to put in place of the context being replaced. Ex: <code class="code">ref="php-block"</code>
</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.28.1</div>
</body>
</html>