@@ 1431-1458 (lines=28) @@ | ||
1428 | title_str = ' title="%s"' % title |
|
1429 | else: |
|
1430 | title_str = '' |
|
1431 | if is_img: |
|
1432 | img_class_str = self._html_class_str_from_tag("img") |
|
1433 | result = '<img src="%s" alt="%s"%s%s%s' \ |
|
1434 | % (_html_escape_url(url, safe_mode=self.safe_mode), |
|
1435 | _xml_escape_attr(link_text), |
|
1436 | title_str, |
|
1437 | img_class_str, |
|
1438 | self.empty_element_suffix) |
|
1439 | if "smarty-pants" in self.extras: |
|
1440 | result = result.replace('"', self._escape_table['"']) |
|
1441 | curr_pos = start_idx + len(result) |
|
1442 | text = text[:start_idx] + result + text[match.end():] |
|
1443 | elif start_idx >= anchor_allowed_pos: |
|
1444 | if self.safe_mode and not self._safe_protocols.match(url): |
|
1445 | result_head = '<a href="#"%s>' % (title_str) |
|
1446 | else: |
|
1447 | result_head = '<a href="%s"%s>' % (_html_escape_url(url, safe_mode=self.safe_mode), title_str) |
|
1448 | result = '%s%s</a>' % (result_head, link_text) |
|
1449 | if "smarty-pants" in self.extras: |
|
1450 | result = result.replace('"', self._escape_table['"']) |
|
1451 | # <img> allowed from curr_pos on, <a> from |
|
1452 | # anchor_allowed_pos on. |
|
1453 | curr_pos = start_idx + len(result_head) |
|
1454 | anchor_allowed_pos = start_idx + len(result) |
|
1455 | text = text[:start_idx] + result + text[match.end():] |
|
1456 | else: |
|
1457 | # Anchor not allowed here. |
|
1458 | curr_pos = start_idx + 1 |
|
1459 | else: |
|
1460 | # This id isn't defined, leave the markup alone. |
|
1461 | curr_pos = match.end() |
|
@@ 1376-1403 (lines=28) @@ | ||
1373 | .replace('_', self._escape_table['_'])) |
|
1374 | else: |
|
1375 | title_str = '' |
|
1376 | if is_img: |
|
1377 | img_class_str = self._html_class_str_from_tag("img") |
|
1378 | result = '<img src="%s" alt="%s"%s%s%s' \ |
|
1379 | % (_html_escape_url(url, safe_mode=self.safe_mode), |
|
1380 | _xml_escape_attr(link_text), |
|
1381 | title_str, |
|
1382 | img_class_str, |
|
1383 | self.empty_element_suffix) |
|
1384 | if "smarty-pants" in self.extras: |
|
1385 | result = result.replace('"', self._escape_table['"']) |
|
1386 | curr_pos = start_idx + len(result) |
|
1387 | text = text[:start_idx] + result + text[url_end_idx:] |
|
1388 | elif start_idx >= anchor_allowed_pos: |
|
1389 | if self.safe_mode and not self._safe_protocols.match(url): |
|
1390 | result_head = '<a href="#"%s>' % (title_str) |
|
1391 | else: |
|
1392 | result_head = '<a href="%s"%s>' % (_html_escape_url(url, safe_mode=self.safe_mode), title_str) |
|
1393 | result = '%s%s</a>' % (result_head, _xml_escape_attr(link_text)) |
|
1394 | if "smarty-pants" in self.extras: |
|
1395 | result = result.replace('"', self._escape_table['"']) |
|
1396 | # <img> allowed from curr_pos on, <a> from |
|
1397 | # anchor_allowed_pos on. |
|
1398 | curr_pos = start_idx + len(result_head) |
|
1399 | anchor_allowed_pos = start_idx + len(result) |
|
1400 | text = text[:start_idx] + result + text[url_end_idx:] |
|
1401 | else: |
|
1402 | # Anchor not allowed here. |
|
1403 | curr_pos = start_idx + 1 |
|
1404 | continue |
|
1405 | ||
1406 | # Reference anchor or img? |