Extra-syntaxes: Added Markdown parser

This commit is contained in:
DancingQuanta 2018-09-22 22:54:49 +01:00 committed by Tomas Babej
parent 8d8fd2c20b
commit 09f01333be

View file

@ -41,47 +41,96 @@ GENERIC_TASK = re.compile(''.join([
DATETIME_FORMAT = "(%Y-%m-%d %H:%M)" DATETIME_FORMAT = "(%Y-%m-%d %H:%M)"
DATE_FORMAT = "(%Y-%m-%d)" DATE_FORMAT = "(%Y-%m-%d)"
GENERIC_VIEWPORT = re.compile( VIEWPORT = {
'^' # Starts at the beginning of the line 'default':
'[=]+' # Heading beginning re.compile(
'(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign '^' # Starts at the begging of the line
# Cannot include '[', '=', '|, and '{' '[=]+' # Heading begging
'\|' # Colon '(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign
'(?P<filter>[^=\|]+?)' # Filter # Cannot include '[', '=', '|, and '{'
'(' # Optional defaults '\|' # Colon
'\|' # Colon '(?P<filter>[^=\|]+?)' # Filter
'(?P<defaults>[^=\|]+?)' # Default attrs '(' # Optional defaults
')?' '\|' # Colon
'\s*' # Any whitespace '(?P<defaults>[^=\|]+?)' # Default attrs
'(#(?P<source>[A-Z]))?' # Optional source indicator ')?'
'\s*' # Any whitespace '\s*' # Any whitespace
'(\$(?P<sort>[A-Z]))?' # Optional sort indicator '(#(?P<source>[A-Z]))?' # Optional source indicator
'\s*' # Any whitespace '\s*' # Any whitespace
'[=]+' # Header ending '(\$(?P<sort>[A-Z]))?' # Optional sort indicator
'\s*' # Any whitespace
'[=]+' # Header ending
),
'markdown':
re.compile(
'^' # Starts at the begging of the line
'[#]+' # Heading begging
'(?P<name>[^#\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|, and '{'
'\|' # Colon
'(?P<filter>[^#\|]+?)' # Filter
'(' # Optional defaults
'\|' # Colon
'(?P<defaults>[^#\|]+?)'# Default attrs
')?'
'\s*' # Any whitespace
'(#(?P<source>[A-Z]))?' # Optional source indicator
'\s*' # Any whitespace
'(\$(?P<sort>[A-Z]))?' # Optional sort indicator
'\s*' # Any whitespace
'$' # End of line
) )
}
GENERIC_PRESET = re.compile( HEADER = {
'^' # Starts at the beginning of the line 'default':
'(?P<header_start>[=]+)' # With a positive number of = re.compile(
'([^=\|\[\{]*)' # Heading caption, everything up to || '^' # Starts at the beginning of the line
# Cannot include '[', '=', '|, and '{' '(?P<header_start>[=]+)' # With a positive number of =
'\|\|' # Delimiter '[^=]+' # Character other than =
'(?P<filter>[^=\|]+?)' # Filter preset '[=]+' # Positive number of =, closing the header
'(' # Optional defaults '\s*' # Allow trailing whitespace
'\|\|' # Delimiter ),
'(?P<defaults>[^=\|]+?)' # Default attrs preset 'markdown':
')?' re.compile(
'\s*' # Any whitespace '^' # Starts at the beginning of the line
'[=]+' # Header ending '(?P<header_start>[#]+)' # With a positive number of #
'[^#]+' # Character other than #
) )
}
GENERIC_HEADER = re.compile( PRESET = {
'^' # Starts at the beginning of the line 'default':
'(?P<header_start>[=]+)' # With a positive number of = re.compile(
'[^=]+' # Character other than = '^' # Starts at the beginning of the line
'[=]+' # Positive number of =, closing the header '(?P<header_start>[=]+)' # With a positive number of =
'\s*' # Allow trailing whitespace '([^=\|\[\{]*)' # Heading caption, everything up to ||
) # Cannot include '[', '=', '|, and '{'
'\|\|' # Delimiter
'(?P<filter>[^=\|]+?)' # Filter preset
'(' # Optional defaults
'\|\|' # Delimiter
'(?P<defaults>[^=\|]+?)' # Default attrs preset
')?'
'\s*' # Any whitespace
'[=]+' # Header ending
),
'markdown':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[#]+)' # With a positive number of #
'([^#\|\[\{]*)' # Heading caption, everything up to ||
# Cannot include '[', '#', '|, and '{'
'\|\|' # Delimiter
'(?P<filter>[^#\|]+?)' # Filter preset
'(' # Optional defaults
'\|\|' # Delimiter
'(?P<defaults>[^#\|]+?)' # Default attrs preset
')?'
'\s*' # Any whitespace
'$' # End of line
)
}
ANSI_ESCAPE_SEQ = re.compile( ANSI_ESCAPE_SEQ = re.compile(
'\x1b' # literal ESC '\x1b' # literal ESC