regexp: Fix empty viewport filters in markdown

In markdown, there's no ' =' after '|', so the '+' in the filter regex
doesn't match. Let's allow filter to be empty and distinguish between
viewports and presets using negative look-ahead.

This fixes the failing TestViewportsTaskGenerationEmptyFilter test.
This commit is contained in:
Tomas Janousek 2020-06-30 11:06:58 +02:00 committed by Tomas Babej
parent 7663a58793
commit 625c26d59f

View file

@ -47,11 +47,12 @@ VIEWPORT = {
r'^' # Starts at the begging of the line
r'[=]+' # Heading begging
r'(?P<name>[^=\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|, and '{'
r'\|' # Colon
r'(?P<filter>[^=\|]+?)' # Filter
# Cannot include '[', '=', '|', and '{'
r'\|' # Bar
r'(?!\|)' # (But not two, that would be a preset)
r'(?P<filter>[^=\|]*?)' # Filter
r'(' # Optional defaults
r'\|' # Colon
r'\|' # Bar
r'(?P<defaults>[^=\|]+?)' # Default attrs
r')?'
r'\s*' # Any whitespace
@ -66,11 +67,12 @@ VIEWPORT = {
r'^' # Starts at the begging of the line
r'[#]+' # Heading begging
r'(?P<name>[^#\|\[\{]*)' # Name of the viewport, all before the | sign
# Cannot include '[', '=', '|, and '{'
r'\|' # Colon
r'(?P<filter>[^#\|]+?)' # Filter
# Cannot include '[', '#', '|', and '{'
r'\|' # Bar
r'(?!\|)' # (But not two, that would be a preset)
r'(?P<filter>[^#\|]*?)' # Filter
r'(' # Optional defaults
r'\|' # Colon
r'\|' # Bar
r'(?P<defaults>[^#\|]+?)' # Default attrs
r')?'
r'\s*' # Any whitespace