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,9 +41,11 @@ 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(
'^' # Starts at the begging of the line
'[=]+' # Heading begging
'(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign '(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|, and '{' # Cannot include '[', '=', '|, and '{'
'\|' # Colon '\|' # Colon
@ -58,9 +60,48 @@ GENERIC_VIEWPORT = re.compile(
'(\$(?P<sort>[A-Z]))?' # Optional sort indicator '(\$(?P<sort>[A-Z]))?' # Optional sort indicator
'\s*' # Any whitespace '\s*' # Any whitespace
'[=]+' # Header ending '[=]+' # 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 = {
'default':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[=]+)' # With a positive number of =
'[^=]+' # Character other than =
'[=]+' # Positive number of =, closing the header
'\s*' # Allow trailing whitespace
),
'markdown':
re.compile(
'^' # Starts at the beginning of the line
'(?P<header_start>[#]+)' # With a positive number of #
'[^#]+' # Character other than #
)
}
PRESET = {
'default':
re.compile(
'^' # Starts at the beginning of the line '^' # Starts at the beginning of the line
'(?P<header_start>[=]+)' # With a positive number of = '(?P<header_start>[=]+)' # With a positive number of =
'([^=\|\[\{]*)' # Heading caption, everything up to || '([^=\|\[\{]*)' # Heading caption, everything up to ||
@ -73,15 +114,23 @@ GENERIC_PRESET = re.compile(
')?' ')?'
'\s*' # Any whitespace '\s*' # Any whitespace
'[=]+' # Header ending '[=]+' # Header ending
) ),
'markdown':
GENERIC_HEADER = re.compile( re.compile(
'^' # Starts at the beginning of the line '^' # Starts at the beginning of the line
'(?P<header_start>[=]+)' # With a positive number of = '(?P<header_start>[#]+)' # With a positive number of #
'[^=]+' # Character other than = '([^#\|\[\{]*)' # Heading caption, everything up to ||
'[=]+' # Positive number of =, closing the header # Cannot include '[', '#', '|, and '{'
'\s*' # Allow trailing whitespace '\|\|' # 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