Permalink
Browse files

different approach to escaping the esc char

  • Loading branch information...
1 parent 6b39487 commit aa422c2d8553f62c7cee94eb0a81b864e4e83223 @EdwardBetts EdwardBetts committed Oct 11, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 openlibrary/catalog/marc/html.py
View
6 openlibrary/catalog/marc/html.py
@@ -1,14 +1,14 @@
from openlibrary.catalog.marc.fast_parse import get_all_tag_lines, translate, split_line
import re
-trans = {'&':'&amp;','<':'&lt;','>':'&gt;','\n':'<br>'}
-re_html_replace = re.compile('([&<>\n])')
+trans = {'&':'&amp;','<':'&lt;','>':'&gt;','\n':'<br>', '\x1b': '<b>[esc]</b>'}
+re_html_replace = re.compile('([&<>\n\x1b])')
def esc(s):
return re_html_replace.sub(lambda m: trans[m.group(1)], s)
def esc_sp(s):
- return esc(s).replace(' ', '&nbsp;').replace('\x1b', '<b>[esc]</b>')
+ return esc(s).replace(' ', '&nbsp;')
class html_record():
def __init__(self, data):

0 comments on commit aa422c2

Please sign in to comment.