From: W. Trevor King Date: Mon, 2 Apr 2012 16:51:15 +0000 (-0400) Subject: Add LaTeX escaping for the dot operator and mark latex_safe output as safe. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a93cde84245a7aa27412b650fefde21657ce7db8;p=chemdb.git Add LaTeX escaping for the dot operator and mark latex_safe output as safe. Without the `safe` filter, Django HTML-escapes the text, which is not what you want for valid LaTeX. --- diff --git a/chemdb/templates/chemdb/doc/door.tex b/chemdb/templates/chemdb/doc/door.tex index 1908f75..555a412 100644 --- a/chemdb/templates/chemdb/doc/door.tex +++ b/chemdb/templates/chemdb/doc/door.tex @@ -28,7 +28,7 @@ \multicolumn{3}{c}{\Tstrut {{ title }} } \\ {% for chemical_instance in instance_group %} {{ chemical_instance.amount }} & {{ chemical_instance.id }} & - {{ chemical_instance.chemical.name|latex_safe }} \\ + {{ chemical_instance.chemical.name|latex_safe|safe }} \\ {% endfor %} {% endif %} {% endfor %} diff --git a/chemdb/templates/chemdb/doc/inventory.tex b/chemdb/templates/chemdb/doc/inventory.tex index 4c724ef..18c18ee 100644 --- a/chemdb/templates/chemdb/doc/inventory.tex +++ b/chemdb/templates/chemdb/doc/inventory.tex @@ -38,7 +38,7 @@ ID & Name & Amount & H & F & R & O & M & C & T \\ \hline \endhead{% for chemical_instance in chemical_instances %} {{ chemical_instance.id }} & - {{ chemical_instance.chemical.name|latex_safe }} & + {{ chemical_instance.chemical.name|latex_safe|safe }} & {{ chemical_instance.amount }} & {{ chemical_instance.chemical.health }} & {{ chemical_instance.chemical.fire }} & diff --git a/chemdb/templatetags/latex.py b/chemdb/templatetags/latex.py index da09d07..7425c24 100644 --- a/chemdb/templatetags/latex.py +++ b/chemdb/templatetags/latex.py @@ -9,7 +9,8 @@ register = _template.Library() LATEX_REPLACEMENTS = [ - ('%', r'\%'), ('>', '$>$'), ('<', '$<$'), (u'\u2026', r'\ldots')] + ('%', r'\%'), ('>', '$>$'), ('<', '$<$'), (u'\u2026', r'\ldots'), + (u'\u22c5', '$\cdot$')] _SUPERSCRIPT_CODEPOINTS = {1: 0x00B9, 2: 0x00B2, 3: 0x00B3} for i in range(9): subscript_codepoint = 0x2080 + i