Add LaTeX escaping for the dot operator and mark latex_safe output as safe.
authorW. Trevor King <wking@drexel.edu>
Mon, 2 Apr 2012 16:51:15 +0000 (12:51 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 2 Apr 2012 16:53:27 +0000 (12:53 -0400)
Without the `safe` filter, Django HTML-escapes the text, which is not
what you want for valid LaTeX.

chemdb/templates/chemdb/doc/door.tex
chemdb/templates/chemdb/doc/inventory.tex
chemdb/templatetags/latex.py

index 1908f7509eee7afb094cca6c17a9ea15e07fa893..555a4129a6864d186e78dcdcf95af562befea562 100644 (file)
@@ -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 %}
index 4c724ef7ea5dd36fa3a92305f63188e2a2931d5c..18c18eeae3382a59ae1377a4f75ed9c1f2e86c03 100644 (file)
@@ -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 }} &
index da09d0762a7286e0b7d02d2b597d1d28451993e2..7425c2464153ca401ae3f8425f152c7213f752e6 100644 (file)
@@ -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