Since: Concordion 2.0.0
With the Markdown extension, Concordion commands are expressed using Markdown links, for example:
[value](- "command")
This format separates the instrumentation (command
) from the specification (value
). When viewed with a Markdown editor only the specification is shown, with the instrumentation displayed as a title when you hover over the value
. The URL has to be set to -
, otherwise it will be treated as a normal Markdown link.
The Markdown extension converts the Markdown to XHTML, with the instrumentation as attributes, prior to running Concordion with the XHTML format specification as input.
This specification describes the grammar for the Markdown instrumentation and checks that it generates correctly formatted instrumentation in XHTML.
The extension supports both inline links and reference links.
In both styles, the text value
is delimited by square brackets.
Inline links have a set of regular parentheses immediately after the link text’s closing square bracket. Inside the parentheses are a -
for the URL followed by a space followed by the command, surrounded in quotes (either single or double quotes are allowed). For example:
Markdown | Resultant HTML |
---|---|
[Jane Doe](- '#name') | <span concordion:set="#name">Jane Doe</span> |
As an alternative to inline links, reference links can be used. This can help make the Markdown source more readable, especially for table headers or lengthy commands.
Reference links have a set of square brackets immediately after the link text’s closing square bracket. The link definition can then be placed anywhere in the document. See the Markdown syntax page for more details.
Markdown | Resultant HTML |
---|---|
My name is [Jane Doe][name] [name]: - "?=getFullName()" |
My name is <span concordion:assert-equals="getFullName()">Jane Doe</span> |
If the link text is the same as the link name, you can use implicit links:
Markdown | Resultant HTML |
---|---|
will be [split][] into [split]: - "#result = split(#name)" |
will be <span concordion:execute="#result = split(#name)">split</span> into |
Some commands only require an expression and don't need a text value to be passed. However, Markdown links always require link text.
Any text value that starts with italics will be set to an empty text value in the output specification.
Markdown | Resultant HTML |
---|---|
[_set time_](- "setCurrentTime(#time)") | <span concordion:execute="setCurrentTime(#time)"></span> |
Any Concordion command can be included in the title of the Markdown link by using the prefix c:
.
Note that, unlike HTML format specifications, the expression is not enclosed in additional quotes. Neither are the value of any additional parameters passed to the command.
Markdown | Resultant HTML |
---|---|
[value](- "c:command=expression") |
<span concordion:command="expression">value</span> |
[value](- "c:command=expression param=x") |
<span concordion:command="expression" param="x">value</span> |
[value](- "c:command=expression param1=x param2=y") |
<span concordion:command="expression" param1="x" param2="y">value</span> |
For cases where the Markdown syntax is too restrictive, you can inline HTML.
This can be used to embed Concordion structures that are not currently supported by the Markdown syntax.
The execute on a list command can be implemented using the HTML list structure, wrapped in a <div>
element. For example:
<div>
<ol concordion:execute="parseNode(#TEXT, #LEVEL)">
<li>Europe</li>
<ul>
<li>Austria</li>
<ol>
<li>Vienna</li>
</ol>
<li>UK</li>
<ul>
<li>England</li>
<li>Scotland</li>
</ul>
<li>France</li>
</ul>
<li>Australia</li>
</ol>
</div>
In order to handle unusual sentence structures, Concordion allows you to use an execute
command on an outer HTML element. When using Markdown, this can be implemented using the HTML structure wrapped in a <div>
.
<div>
<p concordion:execute="#greeting = greetingFor(#firstName)">
The greeting "<span concordion:assertEquals="#greeting">Hello Bob!</span>"
should be given to user <span concordion:set="#firstName">Bob</span>
when he logs in.
</p>
</div>
The set, assert-equals and execute commands require the link URL to be set to -
. Links with other URLs are not modified. For example:
Markdown | Resultant HTML |
---|---|
[John](- "#a") | <span concordion:set="#a">John</span> |
[John](john.html) | <a href="john.html">John</a> |
[John](john.html "Details about John") | <a href="john.html" title="Details about John">John</a> |
[John](john.html "#More about John") | <a href="john.html" title="#More about John">John</a> |
[John](-.html "Weird URL") | <a href="-.html" title="Weird URL">John</a> |
[John](.) | <a href=".">John</a> |
[John](#) | <a href="#">John</a> |
In order to include Concordion commands with namespaces other than the default Concordion namespaces, such as those available in extensions, you must declare the namespace.
Add the @ConcordionOptions
annotation to the fixture class, with the declareNamespaces
element set to a list of strings, where the values alternate between namespace prefixes and the namespace they are mapped to. For example:
@RunWith(ConcordionRunner.class)
@ConcordionOptions(declareNamespaces={"ext", "urn:concordion-extensions:2010"})
public class MyFixture
The namespaced command can then be included in the title of the Markdown link, using the prefix declared in the annotation.
Markdown | Resultant HTML |
---|---|
[-](- "ext:embed=getDetails()") | <span ext:embed="getDetails()">-</span> |
Commands can be formatted with bold or italic text
Markdown | Resultant HTML |
---|---|
__[a](- "#b")__ | <strong><span concordion:set="#b">a</span></strong> |
*[c](- "#d")* | <em><span concordion:set="#d">c</span></em> |
Multiple commands on the same line are supported.
Markdown | Resultant HTML |
---|---|
[1](- "#x") + [2](- "#y") = [3](- "?=add(#x,#y)") | <span concordion:set="#x">1</span> + <span concordion:set="#y">2</span> = <span concordion:assert-equals="add(#x,#y)">3</span> |
[3](- "?=three()"). [Fred](- "#name"). | <span concordion:assert-equals="three()">3</span>. <span concordion:set="#name">Fred</span>. |
HTML entities in the text value are automatically escaped.
Markdown | Resultant HTML |
---|---|
[& < 3](- "#x") | <span concordion:set="#x">& < 3</span> |
[<div>](- "#d") | <span concordion:set="#d"><div></span> |
[<div class="x">](- "#d") | <span concordion:set="#d"><div class="x"></span> |
[<request>](- "#d") | <span concordion:set="#d"><request></span> |
[<div><br/></div>](- "#d") | <span concordion:set="#d"><div><br/></div></span> |
[<?xml version='1.0' encoding='UTF-8'?>](- "#decl") | <span concordion:set="#decl"><?xml version='1.0' encoding='UTF-8'?></span> |
[& < 3](- "c:set=#x") | <span concordion:set="#x">& < 3</span> |
[<div>](- "c:set=#d") | <span concordion:set="#d"><div></span> |
[& < 3][] [& < 3]: - "c:set=#x" | <span concordion:set="#x">& < 3</span> |
[<div>][xx] [xx]: - "#d" | <span concordion:set="#d"><div></span> |
|[foo](- "foo()")|[a < b](- "#d")|[x>](- "?=#d")| | -------------- | ------------- | ------------ | | bar | a < b | x>| | <table concordion:execute="foo()"> <thead> <tr><th></th><th concordion:set="#d">a < b</th><th concordion:assert-equals="#d">x></th></tr> </thead> <tbody> <tr><td> bar </td><td> a < b </td><td> x></td></tr> </tbody> </table> |
Markdown | Resultant HTML |
---|---|
é | é |