Concordion > Annotations >

Concordion Options

Since: Concordion 2.0.0

The @ConcordionOptions annotation can be applied to specifications to configure aspects of Concordion.

Saving Source HTML

For debug purposes, you may wish to save a copy of the source HTML. For example, when using Markdown format, you may want to see the HTML that is generated by the Markdown parser, and used as the input specification to Concordion.

To save a copy, use the @ConcordionOptions annotation on the fixture class with the value of copySourceHtmlToDir set to the target directory. For example:

@RunWith(ConcordionRunner.class)
@ConcordionOptions(copySourceHtmlToDir="/tmp")
public class ...

The target directory can include system property values in the path, by wrapping the system property key in ${ and }. For example:

@ConcordionOptions(copySourceHtmlToDir="${java.io.tmpdir}/output")

will write to the output directory under the system temp folder.

Markdown Syntax Extensions

Markdown extensions allow you to change and/or extend the behaviour of the Markdown parser, for example to change the behaviour of new lines, or to support definition lists.

We support two types of extensions - Flexmark options and Pegdown extensions.

FlexmarkOptions provides a wider range of extensions and a greater level of control and is the preferred way of adding Markdown extensions.

Pegdown Extensions

The original parser in use was Pegdown. However, since this has now been deprecated by the author, it has been replaced by the Flexmark parser. (since Concordion 3.0.0)

This legacy way of adding extensions continues to be supported by Concordion.

To add Pegdown extensions, use the @ConcordionOptions annotation on the fixture class with the value of markdownExtensions set to an array of MarkdownExtension enumerations. For example:

@RunWith(ConcordionRunner.class)
@ConcordionOptions(markdownExtensions={MarkdownExtensions.WIKILINKS, MarkdownExtensions.AUTOLINKS})
public class ...

See the MarkdownExtension javadoc for a definition of the available extensions, and the Pegdown documentation for more details on each extension.

No extra extensions

Without additional extensions, the following are translated as-is.

Example

Markdown Resulting HTML
[[not a wikilink]] [[not a wikilink]]
https://concordion.org https://concordion.org

With WIKILINKS and QUOTES extensions

Given the method withPegdownExtensions(int options) has been called with options set to org.pegdown.Extensions.WIKILINKS | org.pegdown.Extensions.AUTOLINKS, the following are now translated as shown:

Example

Markdown Resulting HTML
[[wikilink]] <a href="wikilink">wikilink</a>
https://concordion.org <a href="https://concordion.org">https://concordion.org</a>

Additional namespace declarations

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.

This is only applicable to Markdown specifications. In HTML specifications, the namespaces are declared directly in the HTML.

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

Valid declarations

declareNamespaces valueNamespace mappings
{"ext", "urn:concordion-extensions:2010"} {"ext"= "urn:concordion-extensions:2010"}
{"foo", "http://bar", "x", "urn:baz"} { "x"= "urn:baz", "foo"= "http://bar"}

Invalid declarations

If passing an odd number of arguments, an error will occur:

declareNamespaces valueException message
{"foo", "http://bar", "x"} The declareNamespaces element of @ConcordionOptions must include an even number of arguments, alternating between a namespace prefix and the namespace it maps to