ExPar (InstanceTopic, 4)

From Kawachan

Revision as of 14:07, 19 February 2011 by Keiji (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

ExPar is a scripting language used by Kawachan to set metadata about a page or to invoke special functionality. This page explains how it can be used.

Syntax

A block of ExPar code is surrounded by square brackets ([]). The root block – the block embedded directly into the page and not contained in any other block – is also surrounded by angle brackets (<>), so it appears as <[...]>.

Each block is made up of a list of tokens, separated by spaces. These tokens may be either other blocks, or literals (plain text). The first token in a block is called the key; all others are collectively called the values.

There are two types of keys: command keys and parameter keys. The difference is that command keys start with a hash sign (#) and parameter keys don't. If the key of a block is a command key, the block is called a command block; similarly, if the key is a parameter key, the block is called a parameter block.

The key of a block may be a literal or a command block, but it cannot be a parameter block. If the key is a command block, that command would first be executed to determine whether the parent block is a command or parameter block.

Command blocks are executed from inside to out, i.e. the most deeply nested commands are executed first. When a command block is executed, it returns a list of zero or more blocks, which are inserted into the parent block at the position of that command block. Of course, a command block may include other command blocks in its return value, which would be executed in turn, until no more remain.

The root block must be a command block, and must return a literal (though it can be the empty string). This literal will then be inserted into the page in place of the original ExPar code.

ExPar constructions will be parsed after template inclusions, but before wikilinks.

Links can still be inserted inside ExPar blocks, even though they both use square brackets. Because the string [[x is not legal anywhere in ExPar code (unless x is a hash sign or another opening square bracket), the ExPar parser will notice that this should be a link, and implicitly "escape" it for you. To insert an external link, simply use the same syntax as you would for a wikilink, for example [[http://example.com/|link text]].

Commands

#audio

#box

#db-parse

#img

#linkfarm

#list

#ontology