mirror of https://gitlab.crans.org/bde/nk20
Escape special TeX characters
This commit is contained in:
parent
de5e0c958e
commit
a4702fca86
|
@ -0,0 +1,20 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django import template
|
||||
|
||||
|
||||
def do_latex_escape(value):
|
||||
return (
|
||||
value.replace("&", "\\&")
|
||||
.replace("$", "\\$")
|
||||
.replace("%", "\\%")
|
||||
.replace("#", "\\#")
|
||||
.replace("_", "\\_")
|
||||
.replace("{", "\\{")
|
||||
.replace("}", "\\}")
|
||||
)
|
||||
|
||||
|
||||
register = template.Library()
|
||||
register.filter("escape_tex", do_latex_escape)
|
|
@ -1,3 +1,5 @@
|
|||
{% load escape_tex %}
|
||||
|
||||
\nonstopmode
|
||||
\documentclass[11pt]{article}
|
||||
|
||||
|
@ -83,20 +85,20 @@
|
|||
|
||||
\def\FactureNum {{"{"}}{{ obj.id }}} % Numéro de facture
|
||||
\def\FactureAcquittee {% if obj.acquitted %} {oui} {% else %} {non} {% endif %} % Facture acquittée : oui/non
|
||||
\def\FactureLieu {{"{"}}{{ obj.place }}} % Lieu de l'édition de la facture
|
||||
\def\FactureLieu {{"{"}}{{ obj.place|safe|escape_tex }}} % Lieu de l'édition de la facture
|
||||
\def\FactureDate {{"{"}}{{ obj.date }}} % Date de l'édition de la facture
|
||||
\def\FactureObjet {{"{"}}{{ obj.object|safe }} } % Objet du document
|
||||
\def\FactureObjet {{"{"}}{{ obj.object|safe|escape_tex }} } % Objet du document
|
||||
% Description de la facture
|
||||
\def\FactureDescr {{"{"}}{{ obj.description|safe }}}
|
||||
\def\FactureDescr {{"{"}}{{ obj.description|safe|escape_tex }}}
|
||||
|
||||
% Infos Client
|
||||
\def\ClientNom{{"{"}}{{obj.name|safe}}} % Nom du client
|
||||
\def\ClientAdresse{{"{"}}{{ obj.address|safe }}} % Adresse du client
|
||||
\def\ClientNom{{"{"}}{{ obj.name|safe|escape_tex }}} % Nom du client
|
||||
\def\ClientAdresse{{"{"}}{{ obj.address|safe|escape_tex }}} % Adresse du client
|
||||
|
||||
% Liste des produits facturés : Désignation, quantité, prix unitaire HT
|
||||
|
||||
{% for product in products %}
|
||||
\AjouterProduit{ {{product.designation|safe}}} { {{product.quantity|safe}}} { {{product.amount_euros|safe}}} { {{product.total_euros|safe}}}
|
||||
\AjouterProduit{ {{ product.designation|safe|escape_tex }}} { {{ product.quantity|safe|escape_tex }}} { {{ product.amount_euros|safe|escape_tex }}} { {{ product.total_euros|safe|escape_tex }}}
|
||||
{% endfor %}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
Loading…
Reference in New Issue