Skip to content
This repository
Browse code

different approach to escaping the esc char

  • Loading branch information...
commit aa422c2d8553f62c7cee94eb0a81b864e4e83223 1 parent 6b39487
Edward Betts EdwardBetts authored

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 3 openlibrary/catalog/marc/html.py
6 openlibrary/catalog/marc/html.py
... ... @@ -1,14 +1,14 @@
1 1 from openlibrary.catalog.marc.fast_parse import get_all_tag_lines, translate, split_line
2 2 import re
3 3
4   -trans = {'&':'&amp;','<':'&lt;','>':'&gt;','\n':'<br>'}
5   -re_html_replace = re.compile('([&<>\n])')
  4 +trans = {'&':'&amp;','<':'&lt;','>':'&gt;','\n':'<br>', '\x1b': '<b>[esc]</b>'}
  5 +re_html_replace = re.compile('([&<>\n\x1b])')
6 6
7 7 def esc(s):
8 8 return re_html_replace.sub(lambda m: trans[m.group(1)], s)
9 9
10 10 def esc_sp(s):
11   - return esc(s).replace(' ', '&nbsp;').replace('\x1b', '<b>[esc]</b>')
  11 + return esc(s).replace(' ', '&nbsp;')
12 12
13 13 class html_record():
14 14 def __init__(self, data):

0 comments on commit aa422c2

Please sign in to comment.
Something went wrong with that request. Please try again.