def parse_data(self, text, maxwidth, maxheight, template_dir, context,<EOL>urlize_all_links):
<EOL>replacements = {}<EOL>user_urls = set(re.findall(URL_RE, text))<EOL>for user_url in user_urls:<EOL><INDENT>try:<EOL><INDENT>resource = oembed.site.embed(user_url, maxwidth=maxwidth, maxheight=maxheight)<EOL><DEDENT>except OEmbedException:<EOL><INDENT>if urlize_all_links:<EOL><INDENT>replacements[user_url] = '<STR_LIT>' % {'<STR_LIT>': user_url}<EOL><DEDENT><DEDENT>else:<EOL><INDENT>context['<STR_LIT>'] = min(maxwidth, resource.width)<EOL>context['<STR_LIT>'] = min(maxheight, resource.height)<EOL>replacement = self.render_oembed(<EOL>resource, <EOL>user_url, <EOL>template_dir=template_dir, <EOL>context=context<EOL>)<EOL>replacements[user_url] = replacement.strip()<EOL><DEDENT><DEDENT>user_urls = re.finditer(URL_RE, text)<EOL>matches = []<EOL>for match in user_urls:<EOL><INDENT>if match.group() in replacements:<EOL><INDENT>matches.append([match.start(), match.end(), match.group()])<EOL><DEDENT><DEDENT>for indx, (start, end, user_url) in enumerate(matches):<EOL><INDENT>replacement = replacements[user_url]<EOL>difference = len(replacement) - len(user_url)<EOL>text = text[:start] + replacement + text[end:]<EOL>for j in xrange(indx + <NUM_LIT:1>, len(matches)):<EOL><INDENT>matches[j][<NUM_LIT:0>] += difference<EOL>matches[j][<NUM_LIT:1>] += difference<EOL><DEDENT><DEDENT>return mark_safe(text)<EOL>
Parses a block of text indiscriminately