[svn] improved jinja whitespace processing stuff
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent a6c3ac5 · Browse files · 1 file·+25 added−32 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+25 added−32 removed
- other:+25 added−32 removed
Provenance
- Commit
1151fbc- Tree
e519e2e- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
a6c3ac5
1 file changed+25 added−32 removed
modified:jinja/lexer.py+25 added-32 removed
91 unmodified lines92 93 # global lexing rules94 self.rules = {95 'root': [96- # raw directive with whitespace rule97- (c('(\s*%s\-\sraw\s\-?%s)' % (96+ # raw directive97+ (c('((?:\s*%s\-|%s)\s*raw\s*(?:\-%s\s*|%s%s))' % (98 e(environment.block_start_string),99- e(environment.block_end_string)100- )), (None,), 'raw'),101- # raw directive without whitespace rule102- (c('(%s\sraw\s\-?%s)' % (99 e(environment.block_start_string),104- e(environment.block_end_string)100+ e(environment.block_end_string),101+ e(environment.block_end_string),102+ block_suffix_re103 )), (None,), 'raw'),106- # directives with dropped leading whitespace104+ # normal directives105 (c('(.*?)(?:%s)' % '|'.join([108- '(?P<%s_begin>\s*%s\-)' % (n, e(r)) for n, r in root_tag_rules106+ '(?P<%s_begin>\s*%s\-|%s)' % (n, e(r), e(r))107+ for n, r in root_tag_rules108 ])), ('data', '#bygroup'), '#bygroup'),110- # directives with normal semantics111- (c('(.*?)(?:%s)' % '|'.join([112- '(?P<%s_begin>%s)' % (n, e(r)) for n, r in root_tag_rules113- ])), ('data', '#bygroup'), '#bygroup'),109 # data110 (c('.+'), 'data', None)111 ],112 # comments113 'comment_begin': [119- (c(r'(.*?)(%s)' % e(environment.comment_end_string)),120- ('comment', 'comment_end'), '#pop'),114+ (c(r'(.*?)(\-%s\s*|%s)' % (115+ e(environment.comment_end_string),116+ e(environment.comment_end_string)117+ )), ('comment', 'comment_end'), '#pop'),118 (c('(.)'), (Failure('Missing end of comment tag'),), None)119 ],120 # directives121 'block_begin': [125- # block end with dropping whitespace rule126- (c('\-%s\s*' % e(environment.block_end_string)), 'block_end', '#pop'),127- # regular block end128- (c(e(environment.block_end_string) + block_suffix_re),129- 'block_end', '#pop')122+ (c('\-%s\s*|%s' % (123+ e(environment.block_end_string),124+ e(environment.block_end_string)125+ )), 'block_end', '#pop'),126 ] + tag_rules,127 # variables128 'variable_begin': [133- (c(e(environment.variable_end_string)), 'variable_end',134- '#pop')129+ (c('\-%s\s*|%s' % (130+ e(environment.variable_end_string),131+ e(environment.variable_end_string)132+ )), 'variable_end', '#pop')133 ] + tag_rules,134 # raw block135 'raw': [138- # with whitespace rule139- (c('(.*?)(%s\-?\s*endraw\s*\-%s%s\s*)' % (140- environment.block_start_string,141- environment.block_end_string,136+ (c('(.*?)((?:\s*%s\-|%s)\s*endraw\s*(?:\-%s\s*|%s%s))' % (137+ e(environment.block_start_string),138+ e(environment.block_start_string),139+ e(environment.block_end_string),140+ e(environment.block_end_string),141 block_suffix_re142 )), ('data', None), '#pop'),144- # without whitespace rule145- (c('(.*?)(%s\-?\s*endraw\s*%s%s)' % (146- environment.block_start_string,147- environment.block_end_string,148- block_suffix_re149- )), ('data', None), '#pop'),143 (c('(.)'), (Failure('Missing end of raw directive'),), None)144 ]145 }146 118 unmodified lines