Created
May 16, 2011 22:23
-
-
Save fxthomas/975516 to your computer and use it in GitHub Desktop.
Dokucode (Part)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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