# HG changeset patch # User Jan Kanis # Date 1403103505 -7200 # Node ID 03e044b5bcc2acb5a0a82951d2d77aa39b92f511 # Parent 67b1a319c6dca81f6432d97038feafe186c1a0d3 fix escaping of javascript literals diff -r 67b1a319c6dc -r 03e044b5bcc2 blast2html.py --- a/blast2html.py Wed Jun 18 16:21:45 2014 +0200 +++ b/blast2html.py Wed Jun 18 16:58:25 2014 +0200 @@ -173,18 +173,19 @@ # javascript escape filter based on Django's, from https://github.com/dsissitka/khan-website/blob/master/templatefilters.py#L112-139 # I've removed the html escapes, since html escaping is already being performed by the template engine. +# The r'\u0027' syntax doesn't work the way we need to in python 2.6 with unicode_literals _base_js_escapes = ( - ('\\', r'\u005C'), - ('\'', r'\u0027'), - ('"', r'\u0022'), - # ('>', r'\u003E'), - # ('<', r'\u003C'), - # ('&', r'\u0026'), - # ('=', r'\u003D'), - # ('-', r'\u002D'), - # (';', r'\u003B'), - # (u'\u2028', r'\u2028'), - # (u'\u2029', r'\u2029') + ('\\', '\\u005C'), + ('\'', '\\u0027'), + ('"', '\\u0022'), + # ('>', '\\u003E'), + # ('<', '\\u003C'), + # ('&', '\\u0026'), + # ('=', '\\u003D'), + # ('-', '\\u002D'), + # (';', '\\u003B'), + (u'\u2028', '\\u2028'), + (u'\u2029', '\\u2029') ) # Escape every ASCII character with a value less than 32. This is @@ -337,7 +338,6 @@ def main(): - #import pdb; pdb.set_trace() default_template = path.join(path.dirname(__file__), 'blast2html.html.jinja') parser = argparse.ArgumentParser(description="Convert a BLAST XML result into a nicely readable html page",