Skip to content

Commit

Permalink
Allow space after directives without parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
baradi09 committed Dec 17, 2016
1 parent ecb36c8 commit 7ea228b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/fypp
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ _LINE_DIRECTIVES_PATTERN = r'''
|
# line control directive (with optional continuation lines)
^[ \t]*\#:[ \t]*(?P<ldirective>[^ \t\n]+)
(?:[ \t]+(?P<lparam>.*?(?:&[ \t]*\n[ \t]*&.*?)*))?[ \t]*\n
(?:[ \t]+(?P<lparam>[^ \t].*?(?:&[ \t]*\n[ \t]*&.*?)*))?[ \t]*\n
|
# line eval directive (with optional continuation lines)
^[ \t]*\$:[ \t]*(?P<lexpr>.*?(?:&[ \t]*\n(?:[ \t]*&)?.*?)*)[ \t]*\n
|
# direct call directive (with optional continuation lines)
^[ \t]*@:[ \t]*(?P<callexpr>[^ \t\n]+)
(?:[ \t]+(?P<callparams>.*?(?:&[ \t]*\n[ \t]*&.*?)*))?[ \t]*\n
(?:[ \t]+(?P<callparams>[^ \t].*?(?:&[ \t]*\n[ \t]*&.*?)*))?[ \t]*\n
'''

_INLINE_DIRECTIVES_PATTERN = r'''
# inline control directive
\#\{[ \t]*(?P<idirective>[^ \t\n]+?)(?:[ \t]+(?P<param>.*?))?[ \t]*\}\#
\#\{[ \t]*(?P<idirective>[^ \t\n]+?)(?:[ \t]+(?P<param>[^ \t].*?))?[ \t]*\}\#
|
# inline eval directive
\$\{[ \t]*(?P<iexpr>.*?)[ \t]*\}\$
Expand Down
12 changes: 12 additions & 0 deletions test/test_fypp.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,18 @@ def _linenumbering(nummode):
'123\n'
)
),
('whitespace_but_no_param',
([],
'#:if True\nOK\n#:endif \n',
'OK\n'
)
),
('whitespace_but_no_param_inline',
([],
'#{if True}#OK#{endif }#',
'OK'
)
),
]


Expand Down

0 comments on commit 7ea228b

Please sign in to comment.