Our Lmt language depends is a regular language and depends on a few regular expressions, we are listing them here because both the tangler and weave care about them.
The first regular expression handles the detection of include directives. It recognizes lines like ! include [some description](some-file)
and extracts some-file
.
/^!\s+include\s+\[.*\]\((.*)\)\s*$/
This regular expression handles the detection of include-path directives. It recognizes lines like ! include-path some-path
and extracts some-path
.
/^!\s+include-path\s+(.*)\s*$/
These regular expression recognize if, elseif, else, and end directives. The first group contains the conditional for blocks that have a conditional..
/^!\s+if\s+(.*)$/
/^!\s+else/
/^!\s+elsif\s+(.*)$/
/^!\s+end$/
This expression is intended to note when whe enter or leave a code block. It detects markdown code fences and processes the special directives. It has four groups. The first identifies white space at the beginning of the line. The second detects the language. The third determines if this is a replacement. The fourth is the name of the block (if applicable).
/^(\s*)``` ?([\w]*) ?(=?)([-\w]*)?/
This expression identifies blocks of code which are to be executed. The first group identifies white space at the beginning of the line.
/^(\s*)``` ruby !/
This identifies macro expansions surrounded with ⦅
and ⦆
. The first bit deals with making sure that the opening ⦅
isn't escaped. Then there is one group which contains the name of the macro combined and any filters which are being used.
/(?<!\\)⦅ *([-\w | ]*) *⦆/