comparison genshi/template/markup.py @ 924:3c09c8d8a578

Pull up r1146 to trunk. Addresses #399
author jruigrok
date Mon, 13 Dec 2010 19:07:59 +0000
parents 85e4678337cf
children
comparison
equal deleted inserted replaced
923:8cef75b02ac1 924:3c09c8d8a578
306 """Internal stream filter that applies any defined match templates 306 """Internal stream filter that applies any defined match templates
307 to the stream. 307 to the stream.
308 """ 308 """
309 match_templates = ctxt._match_templates 309 match_templates = ctxt._match_templates
310 310
311 tail = [] 311 def _strip(stream, append):
312 def _strip(stream, append=tail.append):
313 depth = 1 312 depth = 1
314 next = stream.next 313 next = stream.next
315 while 1: 314 while 1:
316 event = next() 315 event = next()
317 if event[0] is START: 316 if event[0] is START:
351 # Consume and store all events until an end event 350 # Consume and store all events until an end event
352 # corresponding to this start event is encountered 351 # corresponding to this start event is encountered
353 pre_end = idx + 1 352 pre_end = idx + 1
354 if 'match_once' not in hints and 'not_recursive' in hints: 353 if 'match_once' not in hints and 'not_recursive' in hints:
355 pre_end -= 1 354 pre_end -= 1
356 inner = _strip(stream) 355 tail = []
356 inner = _strip(stream, tail.append)
357 if pre_end > 0: 357 if pre_end > 0:
358 inner = self._match(inner, ctxt, start=start, 358 inner = self._match(inner, ctxt, start=start,
359 end=pre_end, **vars) 359 end=pre_end, **vars)
360 content = self._include(chain([event], inner, tail), ctxt) 360 content = self._include(chain([event], inner, tail), ctxt)
361 if 'not_buffered' not in hints: 361 if 'not_buffered' not in hints:
Copyright (C) 2012-2017 Edgewall Software