Fenced Code |
This topic details the AMDL syntax and semantics of fenced code blocks.
TBD
Two fenced code block syntaxes are defined:
a line consisting of
n ` (backtick) characters, where n ≥ 3, followed by,
optionally, a language value, followed by,
optionally, an attribute enclosure;
fenced code, consisting of any number of lines, where each line
does not start with l ` characters where l ≥ n;
a line starting with m ` characters where m ≥ n.
a line consisting of
n ~ (tilde) characters, where n ≥ 3, followed by,
optionally, a language value, followed by,
optionally, an attribute enclosure;
fenced code, consisting of any number of lines, where each line
does not start with l ~ characters where l ≥ n;
a line starting with m ~ characters where m ≥ n.
``` First example Backtick code block ``` ~~~ Second example Tilde code block ~~~
Fenced code attributes maybe specified using the following syntax:
{#identifier .class1 .class2 name1="value1" name2="value2" ...}
The following attributes are defined:
any of the following:
language - equivalent to specifying language="language".
command - the content will be rendered as a command (no inner formatting allowed).
noRegionMarkers - equivalent to specifying noRegionMarkers="true".
numberLines - equivalent to specifying numberLines="true".
keepSeeTags - equivalent to specifying keepSeeTags="true".
one of the following:
C
C++ or cpp
C# or CSharp
F# or FSharp
JavaScript or js
HTML or XML or XSL
PowerShell
Python
SQL
VB.NET
If no value is specified, the trailing content of the block's opening line shall be used.
a string value to be used as the block's caption. If no value is specified, the value of the language attribute shall be used.
a string value specifying the path to the file the code block's content should be extracted from. If a value is specified, the code block's contents shall be ignored.
a string value specifying the name of the region the code block's content should be extracted from. If no value is specified, the entire file contents shall be imported.
a Boolean value indicating whether the #region and #endregion tags should be excluded from the extracted content. If no value is specified, the #region and #endregion tags shall be included.
an integer value specifying the number of spaces that will be used for replacing tab characters in the code block. If 0 or no value is specified, the language's default shall be used.
a Boolean value indicating whether the lines in the code block should be numbered. If no value is specified, the line numbers shall be excluded.
a Boolean value indicating whether #region and #if blocks should be collapsible. If no value is specified, region outlining shall be disabled.
a Boolean value indicating whether see tags should be rendered as clickable links. If no value is specified, the see tags shall be rendered as literal text.
One or more nested code blocks may be included in a fenced code block by using a different delimiter (i.e., tildes if backticks were used in the enclosing block, and vice versa). This allows importing code from multiple sources/regions into a single code block.
Note |
---|
No nesting beyond a single level is permitted. |
```C# ~~~{source="Class1.cs"} ~~~ ~~~{source="Class2.cs"} ~~~ ```
~~~{source="Class1.cs"} ~~~ ~~~{source="Class2.cs"} ~~~
Nested code blocks are undefined in PM.
Blank lines before or after fenced code block are not mandatory.
The startFrom attribute is unsupported.
Pandoc's Markdown: Fenced Code Blocks refers to tilde code blocks as fenced code blocks, while backtick code blocks are interpreted as a distinct element. In practice, there are no syntactic or semantic differences between PM and AMDL.
Partial, pending parser modification.
Attributes are unsupported.
Nested code blocks are unsupported.