xwiki/xwiki-rendering — pull request #5 by jirutka (2013-06-25 22:32:11+00:00)
Title: Improve Markdown syntax with macros, superscript and subscript [XRENDERING-297]

Markdown syntax in XWiki supports only the features provided by PegDown parser, it lacks support for macros etc. Therefore it cannot be used as a full replacement of XWiki 2.x syntax.

I like Markdown a lot, this was actually one of the reasons why I’ve chosen XWiki. Although it’s limited, it was very simple to extend it, thanks to its awesomely clean and modular architecture!

So I’ve implemented support for block and inline macros (the most important) and also superscript and subscript formatting for now. PegDown is extensible since version 1.4.0, so the extra parser is implemented as a PegDown plugin.

### Block macro
Same as in XWiki:

```
{{mymacro par1="val1"}}
content
{{/mymacro}}
```

### Inline macro

I can’t find any Markdown dialect with macros so I’ve come with my own, derived from the image and link syntax. It’s quite intuitive and simple.

```
#[mymacro par1=val1 par2="val 2"](any content) with some content
and parameters or this one #[mymacro] without content and parameters.
```

### Superscript and subscript

This is common feature in many Markdown dialects (Pandoc, Multimarkdown, …)

```
This is ^superscript^, but ^this not^, you have to ^escape\ spaces^.
Subscripts are similar, just use ~tilda~ instead.
```

JIRA: [XRENDERING-297](http://jira.xwiki.org/browse/XRENDERING-297)