mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
Escape special TeX characters
This commit is contained in:
parent
de5e0c958e
commit
a4702fca86
20
apps/treasury/templatetags/escape_tex.py
Normal file
20
apps/treasury/templatetags/escape_tex.py
Normal file
@ -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
|
\nonstopmode
|
||||||
\documentclass[11pt]{article}
|
\documentclass[11pt]{article}
|
||||||
|
|
||||||
@ -81,22 +83,22 @@
|
|||||||
\def\IBAN{FR76\CodeBanque\CodeGuichet\NCompte\CleRib}
|
\def\IBAN{FR76\CodeBanque\CodeGuichet\NCompte\CleRib}
|
||||||
\def\CodeBic{{"{"}}{{ obj.bic }}}
|
\def\CodeBic{{"{"}}{{ obj.bic }}}
|
||||||
|
|
||||||
\def\FactureNum {{"{"}}{{obj.id}}} % Numéro de facture
|
\def\FactureNum {{"{"}}{{ obj.id }}} % Numéro de facture
|
||||||
\def\FactureAcquittee {% if obj.acquitted %} {oui} {% else %} {non} {% endif %} % Facture acquittée : oui/non
|
\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\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
|
% Description de la facture
|
||||||
\def\FactureDescr {{"{"}}{{ obj.description|safe }}}
|
\def\FactureDescr {{"{"}}{{ obj.description|safe|escape_tex }}}
|
||||||
|
|
||||||
% Infos Client
|
% Infos Client
|
||||||
\def\ClientNom{{"{"}}{{obj.name|safe}}} % Nom du client
|
\def\ClientNom{{"{"}}{{ obj.name|safe|escape_tex }}} % Nom du client
|
||||||
\def\ClientAdresse{{"{"}}{{ obj.address|safe }}} % Adresse du client
|
\def\ClientAdresse{{"{"}}{{ obj.address|safe|escape_tex }}} % Adresse du client
|
||||||
|
|
||||||
% Liste des produits facturés : Désignation, quantité, prix unitaire HT
|
% Liste des produits facturés : Désignation, quantité, prix unitaire HT
|
||||||
|
|
||||||
{% for product in products %}
|
{% 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 %}
|
{% endfor %}
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
Loading…
Reference in New Issue
Block a user