import re DIRECTIVE: "re.Pattern" = re.compile( r""" (\s*) # directives can be indented (?P \.\. # directives start with a comment [ ]? # followed by a space (?P\| # this could be a substitution definition (?P[^|]+)? \|?)? [ ]? ((?P[\w]+):(?!:))? # directives may include a domain (?P([\w-]|:(?!:))+)? # directives have a name (::)? # directives end with '::' ) ([\s]+(?P.*?)\s*$)? # directives may take an argument """, re.VERBOSE, ) """A regular expression to detect and parse partial and complete directives. This does **not** include any options or content that may be included underneath the initial declaration. A number of named capture groups are available. ``name`` The name of the directive, not including the domain prefix. ``domain`` The domain prefix ``directive`` Everything that makes up a directive, from the initial ``..`` up to and including the ``::`` characters. ``argument`` All argument text. ``substitution`` If the directive is part of a substitution definition, this group will contain **Example** Here is an example with a "standard" directive .. include:: ../../../lib/esbonio/tests/doctests/example_directive_pattern.txt And here is an example with a substitution definition .. include:: ../../../lib/esbonio/tests/doctests/example_directive_substitution_pattern.txt """ DIRECTIVE_OPTION: "re.Pattern" = re.compile( r""" (?P\s+) # directive options must be indented (?P