<<

XWiki Syntax Guide

superadmin

2016/12/21 15:56 XWiki - XWiki Syntax Guide

Table of Contents

XWiki Syntax 2.1: All ...... 3

Page 2 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

XWiki Syntax 2.1 XWiki Syntax 2.1: All • General • Introduction • General Remarks • Other Syntaxes • Editing • Paragraphs • Headings • Text Formatting • Horizontal Line • Lists • Definition Lists • New Line/Line Breaks • Links • Tables • Images • Advanced • Verbatim • Quotations • Groups • Escapes • Parameters • Programming • Macros • HTML • Scripts General Introduction 2.1 Introduction

The XWiki Syntax 2.0 has proven to be quite useful and robust in general; however since its introduction a few shortcomings have been found. The corresponding improvements have been consolidated in XWiki Syntax 2.1. Some new features of this syntax are: • Homogenize the link and image syntax for better clarity, consistency and extensibility. • Added ability to display icons, to embed images via the Data URI scheme, to link to files using the UNC notation and to link to relative URLs. Since XWiki Syntax 2.1 is based on XWiki Syntax 2.0 all syntax from XWiki Syntax 2.0 is valid unless the 2.1 specifications suggest differently. In addition to these XWiki-specific syntaxes we've also changed our underlying rendering engine in XWiki Enterprise version 1.7 (was Radeox previously) in favor of our own engine which is superset wrapper around Wikimodel and Doxia (and possibly others in the future). This has allowed us to provide other syntaxes in the : MediaWiki, Confluence, JSPWiki, , TWiki and more. General Remarks 2.0 General Remarks

XWiki Syntax 2.1 corrects some errors or ambiguous syntax entered by the user as shown in the examples in the table below.

Description Example of invalid or ambiguous syntax Fixed XWiki Syntax 2.1 Unclosed text styles **bold **bold** Two standalone elements not separated by 2 | table cell | table cell new lines * list item * list item Two standalone elements not separated by 2 paragraph paragraph new lines ------paragraph paragraph

Page 3 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

Ignored new line at beginning of document paragraph paragraph Not closed heading syntax === heading === heading ===

Other Syntaxes

1.0 Other Syntaxes

The following other syntaxes are implemented in XWiki Enterprise 1.6 and later: • JSPWiki • MediaWiki • Confluence • TWiki • Creole 1.0 • XHTML 1.0 The implementation for these syntaxes is not fully finished yet. For example support for links is not working perfectly yet. We also need to define if we want to extend the original syntaxes to support XWiki-specific features like ability to link to another sub-wiki. Editing Paragraphs 2.0 Paragraphs

Paragraphs are text elements separated by 2 or more new lines. In XWiki Syntax 2.1 new lines are honored which is not the case in XWiki Syntax 1.0 and in Creole Syntax. Feature XWiki Syntax 2.1 Result Simple paragraph This is a paragraph This is a paragraph Paragraph on multiple lines Paragraph on Paragraph on multiple lines multiple lines Two paragraphs Paragraph one Paragraph one Paragraph two Paragraph two Parametrized paragraph (% style="text-align:center;color:blue" %) Centered and blue paragraph Centered and blue paragraph

Headings 2.0 Headings Feature XWiki Syntax 2.1 Result Standard headings = level 1 = == level 2 == level 1 === level 3 ======level 4 ======level 5 ======level 6 ======level 2 level 3 level 4 level 5 level 6 Parameterized headings (% style="color:blue" %) = heading = heading Headings with XWiki Syntax === Heading with **bold** === Heading with bold

Text Formatting 2.0 Text Formatting

New in XWiki Syntax 2.1 over XWiki Syntax 1.0:

Page 4 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

• Spaces are allowed just after the syntax symbols (for example in XWiki Syntax 1.0, this was not possible: * bold *). • Use double symbols when there was only a single symbol in XWiki Syntax 1.0 so that it's less likely that the user will mistakenly use them in text. • Ability to span several lines (wasn't possible in XWiki Syntax 1.0). Feature XWiki Syntax 2.1 Result Bold **bold** bold Underline __underline__ underline Italics //italic// italic Striked out --strike-- strike Monospace ##monospace## monospace

Superscript some ^^superscript^^ some superscript

Subscript some ,,subscript,, some subscript

Horizontal Line 2.0 Horizontal Line There must be 4 or more dashes. Note that this is different from Creole where exactly 4 dashes are required. Feature XWiki Syntax 2.1 Result Simple horizontal line ---- Parametrized horizontal line (% style="color:blue" %) ----

Lists 2.0 Lists Some of the mentioned styles do not work on all browsers. For a comprehensive list follow this link. Feature XWiki Syntax 2.1 Result Bulleted list * item 1 • item 1 ** item 2 *** item 3 • item 2 * item 4 • item 3 • item 4 Numbered list 1. item 1 1. item 1 11. item 2 111. item 3 1. item 2 1. item 4 1. item 3 2. item 4 Mixed list 1. item 1 1. item 1 1*. item 2 1*. item 3 • item 2 1. item 4 • item 3 2. item 4 Square list (% style="list-style-type: square" %) ◾ item 1 * item 1 * item 2 ◾ item 2

Disc list (% style="list-style-type: disc" %) • item 1 * item 1 * item 2 • item 2

Lowercase Alphabetical list (% style="list-style-type: lower-alpha" %)a. item 1 * item 1 * item 2 b. item 2

Uppercase Alphabetical list (% style="list-style-type: upper-alpha" A.%) item 1 * item 1 * item 2 B. item 2

Lowercase Roman list (% style="list-style-type: lower-roman" %)i. item 1 * item 1 * item 2 ii. item 2

Uppercase Roman list (% style="list-style-type: upper-roman" %)I. item 1 * item 1 * item 2 II. item 2

Lowercase Greek list (% style="list-style-type: lower-greek" %)α. item 1 * item 1 * item 2 β. item 2

Uppercase Greek list (% style="list-style-type: upper-greek" %)• item 1 * item 1 • item 2

Page 5 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

* item 2

Hiragana list (% style="list-style-type: hiragana" %) • item 1 * item 1 * item 2 • item 2

Hiragana Iroah list (% style="list-style-type: hiragana-iroha"• %)item 1 * item 1 * item 2 • item 2

Katakana list (% style="list-style-type: katakana" %) • item 1 * item 1 * item 2 • item 2

Katakana Iroha list (% style="list-style-type: katakana-iroha"• %)item 1 * item 1 * item 2 • item 2

Armenian list (% style="list-style-type: armenian" %) • item 1 * item 1 * item 2 • item 2

Hebrew list (% style="list-style-type: hebrew" %) • item 1 * item 1 * item 2 • item 2

Georgian list (% style="list-style-type: georgian" %) ა. item 1 * item 1 * item 2 ბ. item 2

CJK ideographic list (% style="list-style-type: cjk-ideographic"• it%)em 1 * item 1 * item 2 • item 2

Definition Lists 2.0 Definition Lists Feature XWiki Syntax 2.1 Result Standard definition ; term term : definition definition Nested definitions ; term 1 term 1 : definition 1 :; term 2 definition 1 :: definition 2 term 2 definition 2 Parametrized definition (% style="color:blue" %) term ; term : definition definition

New Line/Line Breaks 2.0 New Line Line Breaks

A new line is a carriage return. A line break is a forced new line that can appear anywhere in the text. In XWiki Syntax 2.1 new lines are honored which is not the case in XWiki Syntax 1.0 and in Creole Syntax. Feature XWiki Syntax 2.1 Result Line break Line\\New line Line New line New line Line Line New line New line

Links 2.1 Links Feature XWiki Syntax 2.1 Result Link to a page in the current Space [[WebHome]] WebHome Link with a label [[label>>WebHome]] label XWiki Syntax is supported inside link labels. Link with XWiki Syntax in the label [[**bold label**>>WebHome]] bold label Link to a page with the space specified [[Main.WebHome]] WebHome Link to a subwiki [[subwiki:Main.WebHome]] WebHome Link that opens in a new window [[label>>WebHome||rel="__blank"]] label

Page 6 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

Link to a URL directly in the text This is a URL: http://xwiki.org This is a URL: http://xwiki.org Link to a URL [[http://xwiki.org]] http://xwiki.org Link to a URL with a label [[XWiki>>http://xwiki.org]] XWiki Link to an email address [[[email protected]>>mailto:[email protected]]] [email protected] Image Link [[image:[email protected]>>Space1.Page1]]

Image Link with image parameters [[[[image:[email protected]|| width="26" height="26"]]>>Space1.Page1]]

Link to an attachment on the current page [[text>>attach:img.png]] text Link to an attachment in a different page [[text>>attach:[email protected]]] text Link to an Anchor in a page [[label>>Space.Page||anchor=anchor]] label Link to a Heading in a page [[label>>XWiki.XWikiSyntax|| label anchor=HMyheading]] When you add a Heading, an anchor named "H" followed by the heading title with only alpha characters is created. For example, for a Heading named "My heading", the generated anchor will be "HMyheading". XWiki Syntax 2.1 Link Specification The part in ( ) is required, while the parts in [ ] are optional. The full format of a link is [label>>] (resource) [||parameters] • label: An optional string which will be displayed to the user as the link name when rendered. The label may contain XWiki Syntax. If no label is specified a default label will be generated. The generation pattern can be changed, see the Admin Guide. Example: My Page • resource: A required string with the link reference in one of the following forms • URL: Any URL in the of [url:] (protocol://path). Examples: http://xwiki.org, url:https://svn.xwiki.org/ • url: An optional string identifying the resource as an URL. • Wiki page name reference in the form [doc:] [[wikiName:] space.] (page). Examples: WebHome, Main.WebHome, mywiki:Main.WebHome • doc: An optional string identifying the resource as an XWiki document. • wikiName: An optional string containing the name of a virtual wiki. The link will point to a page inside that virtual wiki. Example: mywiki • space: An optional wiki Space name. If no space is specified the current space is used. Example: Main • page: A required string containing the name of the linked wiki page. Example: WebHome • InterWiki page name reference in the form interwiki: (interWikiAlias:) (page). Example: interwiki:wikipedia:XWiki • interwiki: A required string identifying the resource as an InterWiki link. • interWikiAlias: An optional Inter Wiki alias as defined in the InterWiki Map (see the Admin Guide). Example: wikipedia • page: A required string containing the name of the linked page. Example: XWiki • Attachment reference in the form attach: [wikiPageName@] (attachmentName). Examples: attach:img.png, attach:mywiki:[email protected] • attach:: A required string identifying the resource as attachment. • wikiPageName: An optional string referencing the document that holds the attachment, see "Wiki page name" above. • attachmentName: Name of the attachment as it is stored in the wiki. • Email address in the form mailto: (emailAddress) (#anchor is not valid). Example: mailto:[email protected] • mailto:: A required string identifying the resource as email. • emailAddress: Targeted email address. Example: [email protected] • Relative path reference on the server in the form path: (relPath). Example: path:$doc.getURL('reset') produces target address http://server.domain.com/xwiki/bin/reset/Space/Page where /xwiki/bin/reset/Space/Page is produced by $doc.getURL('reset'). • path: A required string identifying the resource as a relative path. • relPath: A required string containing the relative path of the resource on the server that shall be linked. • UNC (Windows Explorer) reference in the form unc: (path). The link is rendered as a file:// link. Examples: unc:C:\Windows\, unc:\\myserver\path\img.png, unc:home/user/somefile • unc: A required string identifying the resource as a UNC (Windows Explorer) path.

Page 7 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

• path: A required string containing the local path of resource accessible by the user. Examples: C: \Windows\, \\myserver\path\img.png, home/user/somefile • parameters: An optional list of space-separated parameters passed to the link. Example: queryString="mydata1=5&mydata2=Hello" anchor="HTableOfContents" rel="__blank" • queryString: An optional query string for specifying parameters that will be appended to the link target address and used in the rendered URL. Example: url:http://domain.com/path|| queryString="mydata1=5&mydata2=Hello" produces target address http://domain.com/path? mydata1=5&mydata2=Hello • anchor: An optional anchor name pointing to an anchor defined in the referenced link. Note that in XWiki anchors are automatically created for headings. Example: url:http://domain.com/path|| anchor="HTableOfContents" produces target address http://domain.com/path#HTableOfContents • rel: An optional parameter that allows to open link target in new window. Example: rel="__blank" Tables 2.0 Tables

Allows to easily create content in table format. Parameters for table, row or cell are also supported in XWiki Syntax 2.1.

Feature XWiki Syntax 2.1 Result Standard table |=Title 1|=Title 2 Title 1 Title 2 |Word 1|Word 2 Word 1 Word 2 or !=Title 1!=Title 2 !!Word 1!!Word 2

Parametrized table (% style="background-color:red;align=center"Title 1 %) Title 2 |=Title 1|=(% style="background-color:yellow" %)Title 2 |Word 1|Word 2 Word 1 Word 2 Filterable Sortable table {{velocity}} Title 1 Title 2 $xwiki.ssfx.use("js/xwiki/table/table.css") $xwiki.jsfx.use("js/xwiki/table/tablefilterNsort.js",Cell 11 true)Cell 12 {{/velocity}} Cell 21 Cell 22 (% class="grid sortable filterable doOddEven" id="tableid" %) (% class="sortHeader" %)|=Title 1|=Title 2 |Cell 11|Cell 12 |Cell 21|Cell 22

For improved features see the Livetable Macro.

Images 2.1 Images Feature XWiki Syntax 2.1 Result Image from attachment on current page image:img.png

Image from attachment on another page image:[email protected]

Image with parameters [[image:img.png||width="25" height="25"]]

Images located at URL image:http://some/url/img.png

Prepackaged Icons image:icon:accept

Page 8 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

XWiki Syntax 2.1 Image Specification The part in ( ) is required, while the parts in { } are optional. The full format of an image is either image: (reference) or [[image: (reference) {||parameters}]] • image: A required string identifying the resource as image. • reference: The reference to the image that shall be displayed in one of the following forms: • URL: Any URL to an image in the form of protocol://path/imageName. Example: http://domain.org/path/ img.png • Attachment reference in the form {{{wikiName:} space.} page@} (imageName) • wikiName: An optional string containing the name of a virtual wiki. The image reference will point to an image attached to a page inside that virtual wiki. Example: mywiki • space: An optional wiki Space name. If no space is specified the current space is used. Example: Main • page: An optional string containing the name of the wiki page to which the referenced image is attached. Example: WebHome • imageName: A required string containing the name of the image attached to a page as it is stored in the wiki. • Icon reference in the form (icon:) (iconName). Example: icon:accept • icon: A required string identifying the image reference as an icon from the XWiki Icon Set. • iconName: A required string identifying the icon referenced. Example: accept • Data URI in the form (data:) (content). Example: data:image/ png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/ w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== • data: A required string identifying the image as being specified inline using the Data URI scheme. • content: The encoded image. Example: image/ png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/ w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== • parameters: An optional list of space-separated parameters passed to the image. Example: width="800" height="600" alt="img.png" title="My nice image" • HTML attributes: All attributes defined by the HTML standard will be added to the rendered HTML tag. • style: CSS style information that should be applied to the image. Examples: style="float:right;height:50" (image on right side, height 50 px), style="display:block;margin-left:auto;margin-right:auto;width:80%" (image centered, width 80% of block width), style="vertical-align:bottom" (text starts at bottom of picture) • height: A parameter that defines the height of the displayed image. The value should be presented either in pixel (example: height="80") or in pixel related to the height of the block containing the image (example: height="40%"). • width: A parameter that defines the width of the displayed image. The value should be presented either in pixel (example: width="80") or in pixel related to the width of the block containing the image (example: width="40%"). • title: A parameter that defines the title the displayed image which will be visible when hovering the mouse trigger over the image, for instance. Example: title="My nice image" • alt: A parameter that defines which text should be displayed if the browser is not able to display the image. Since this is a required HTML attribute XWiki will use the file name instead if the alt parameter is not defined. Example: alt="img.png" • More: A more in depth explanation on the HTML tag including more attributes can be reviewed on w3.org. • queryString: Allows queries to be passed to the server when creating the download link for the referenced image. Example: queryString="width=100&height=800&keepAspectRatio=true" (keepAspectRatio=true will fail if the width and height parameters are specified in addition to queryString!) Advanced Verbatim 2.0 Verbatim

Allow to enter content that will not be formatted (in other words the XWiki Syntax will not be taken into account).

Feature XWiki Syntax 2.1 Result Verbatim inline Some verbatim {{{**[[not rendered]]**}}} Some verbatim **[[not rendered]]** content content Verbatim block {{{ multi line multi line **verbatim**

Page 9 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

**verbatim** content content }}}

Quotations

2.0 Quotations

Allows to quote some text.

Feature XWiki Syntax 2.1 Result Simple quote > john said this john said this I said ok I said ok Nested quotes > john said this john said this >> marie answered that I said ok marie answered that

I said ok

Groups 2.0 Groups

Groups can be used to insert another document inline directly into the current document. This allows for example to insert complex elements inside a list item or inside a table cell. Groups are delimited by the following syntactic elements: (((...))). One Group can contain another Group and there is no limit of imbrication.

XWiki Syntax 2.1 Result

|=Header 1|=Header 2|=Header 3 Header 1 Header 2 Header 3 |Cell One|((( = Embedded document = Cell One Embedded Cell Three Some embedded paragraph. document * list item one * list item two Some embedded ** sub-item 1 paragraph. ** sub-item 2 ))) | Cell Three • list item one • list item two Next paragraph in the top-level document • sub- item 1 • sub- item 2

Next paragraph in the top-level document

Escapes 2.0 Escapes

Allows to escape XWiki Syntax.

Feature XWiki Syntax 2.1 Result Escape a character This is not a ~[~[link~]~] This is not a [[link]] To enter a ~ character use a double escape: ~~ Escape longer text {{{ some **longer** text //without// some **longer** text //without// formatting (also see "Verbatim") formatting}}}

Parameters 2.0 Parameters

With XWiki Syntax 2.1 it's possible to pass parameters to the different syntax elements and also to blocks of text. This is used for example to style them. You can set any parameter key/value pair you want. The XHTML renderer will pass these parameters as XHTML attributes to the underlying XHTML representation of the different syntax elements.

Page 10 of 11 - last modified by superadmin on 2016/12/21 15:56 XWiki - XWiki Syntax Guide

XWiki Syntax 2.1 Generated XHTML (% class="myClass" style="myStyle" id="myId" %)

heading

= heading =

Programming Macros

2.0 Macros

There is only one kind of macro in XWiki Syntax 2.1, which is called by the syntax: {{macroname param1="value1" ... paramN="valueN"}}...{{/macroname}}. For macros without content there's a short notation: {{macroname param1="value1" ... paramN="valueN"/}}

Feature XWiki Syntax 2.1 Result Rendering Macro with a content {{code language="java"}} System.out.println("Hello World!"); System.out.println("Hello World!"); {{/code}

Rendering Macro without content {{include reference="Space.Page"/}} The referenced page is included in the current page Radeox macros cannot be used in XWiki Syntax 2.1. Thus they have been rewritten as Rendering macros. For the full list of available macros check the Extensions wiki. HTML

2.0 HTML In XWiki Syntax 2.1 HTML or XHTML must be entered by using the HTML macro. XWiki Syntax 2.1 Result {{html}}bold{{/html}} bold In XWiki Syntax 2.1, by default the HTML macro does not understands XWiki Syntax (other macros included since it's XWiki Syntax too). To enable it, use {{html wiki="true"}} . Scripts 2.0 Scripts In XWiki Syntax 1.0 it was possible to enter Velocity scripts anywhere directly in the page. This lead to issues for example when the user was involuntarily entering Velocity content. It was also performance hungry for pages not requiring Velocity content. There were several other technical limitations. Thus in XWiki Syntax 2.1 Velocity scripts must be entered using the velocity macro. Same goes for entering Groovy scripts. Feature XWiki Syntax 2.1 Velocity script {{velocity}} #set ($var = "whatever") {{/velocity}}

Groovy script {{groovy}} def var = "whatever" {{/groovy}}

Page 11 of 11 - last modified by superadmin on 2016/12/21 15:56