From a93cde84245a7aa27412b650fefde21657ce7db8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 2 Apr 2012 12:51:15 -0400 Subject: [PATCH] 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. --- chemdb/templates/chemdb/doc/door.tex | 2 +- chemdb/templates/chemdb/doc/inventory.tex | 2 +- chemdb/templatetags/latex.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) 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 -- 2.26.2