1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-18 07:44:51 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/macros/syntax/Macro Definition Syntax.tid
Myeongjin 80256b4dab Update document in tiddlywiki.com edition
* Add string '.htm' to 'Saving with TiddlyIE'
* Change external links to match locale with wiki language
* Add instructions for use to 'Saving on Android'
* Change string in 'task'
* Change instructions for use in 'Saving on iPad/iPhone'
* Add newline to 'TiddlyDesktop Releases'
* Remove caption from 'Serving TW5 from Android'
* Change link to external in tiddlers which tagged 'Editions'
* Remove string 'index.html' from 'Some of the things you can do with TiddlyWiki'
* Change link 'TiddlyWiki Groups' to 'Forums' in tiddlers which tagged 'Community'
* Remove CamelCase link 'TiddlyWiki' from tiddlers tagged 'Community'
* Change string 'done' to 'Upgrade' in 'UpgradeMechanism'
* Change buttons to images in 'How to export tiddlers'
* Add images about buttons to tiddlers
* Add quotation mark to text 'edit' in 'Signing the Contributor License Agreement'
* Rename 'UsingSVG' to 'Using SVG'
* Change link 'TypedBlockWikiText' to 'Typed Blocks in WikiText' in 'Using SVG'
* Add tiddler 'Using Stamp'
* Add 'rel="noopener noreferrer"' to external links
* Add description about 'rel="noreferrer"' to 'HTML in WikiText'
* Add link of prerelease version about translators edition, and how to translate on Node.js, in 'Translate TiddlyWiki into your language'
* Change string 'dropdown' to 'tab' in 'Installing a plugin from the plugin library'
* Add download button to 'Empty Edition'
2016-07-06 01:10:51 +09:00

53 lines
1.8 KiB
Plaintext

created: 20150220200255000
modified: 20150221222349000
tags: [[Macro Syntax]]
title: Macro Definition Syntax
type: text/vnd.tiddlywiki
<<.preamble """What follows is a formal presentation of the syntax of the `\define` pragma, using [[railroad diagrams|Railroad Diagrams]]. A [[simpler overview|Macro Definitions in WikiText]] is also available.""">>
<$railroad text="""
"\define" space name params [:space] rest
"""/>
<<.place space>> denotes a sequence of [[whitespace characters|Filter Whitespace]].
The [[macro|Macros]]'s <<.place name>> is a sequence of non-whitespace characters other than `(` or `>`.
The parameter declaration list (<<.place params>>) has the following syntax:
<$railroad text="""
"(" [:sep] [:{ param sep }] ")"
"""/>
The parameter separator (<<.place sep>>) is any sequence of characters that does not match a <<.place param-name>>. Among other things, this includes commas, spaces and linefeeds.
A <<.place param-name>> is a sequence of letters (`A`--`Z`, `a`--`z`), digits (`0`--`9`), hyphens (`-`) and underscores (`_`).
Each individual <<.place param>> has the following syntax:
<$railroad text="""
param-name [: [:space] ":" [:space] default ]
")"
"""/>
The optional <<.place default>> value of a parameter is specified as follows:
<$railroad text={{$:/editions/tw5.com/railroad/macro-parameter-value}}/>
The <<.place rest>> of the definition has the following syntax:
<$railroad text="""
( snippet | lf snippet lf "\end" [:space] ) lf
"""/>
<<.place lf>> denotes a linefeed.
The <<.place snippet>> is any sequence of characters that doesn't terminate the macro definition. That is to say, a single-line snippet cannot contain a linefeed, and a multi-line snippet cannot contain `\end` on a line of its own.
The snippet can contain placeholders with the following syntax:
<$railroad text="""
( "$" name "$" | "$" "(" name ")" "$" )
"""/>