Skip to content

Instantly share code, notes, and snippets.

@fxthomas
Created May 16, 2011 22:23
Show Gist options
  • Save fxthomas/975516 to your computer and use it in GitHub Desktop.
Save fxthomas/975516 to your computer and use it in GitHub Desktop.
Dokucode (Part)
# Search text for blocks and replace with format placeholders
def _prep_blocks (text, autoescape=None):
known_upper_tags = [CodeTag, VimeoTag, URLTag, GalleryTag, ImageTag, FileTag, NewzTag]
blocks = []
count = 0
for t in known_upper_tags:
for r in t.Code:
while True:
m = r.search (text)
if m == None:
break
blocks.append (t(m, autoescape))
text = text[:m.start()] + ("{"+str(count)+"}") + text[m.end():]
count = count + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment