Skip to content
Snippets Groups Projects
Commit 0141b00d authored by Jonathan Weth's avatar Jonathan Weth :keyboard: Committed by root
Browse files

Merge pull request #245 from Katharineum/feature/allow-special-characters-latex

Allow greater than character in LaTeX (issue #241)
parents 7868b5d4 f8bb9393
No related branches found
No related tags found
1 merge request!86Merge school-apps
# -*- coding: utf-8 -*-
"""
Django filters, needed when creating LaTeX files with the django template language
Written by Rocco Schulz (http://is-gr8.com/), modified by SchoolApps-Team
"""
from django.template.defaultfilters import stringfilter, register
from django.template.loader import render_to_string
@register.filter
@stringfilter
def brackets(value):
"""
surrounds the value with { }
You have to use this filter whenever you would need something like
{{{ field }}} in a template.
"""
return "{%s}" % value
REPLACEMENTS = {
"§": "\\textsection{}",
"$": "\\textdollar{}",
"LaTeX": "\\LaTeX \\ ",
" TeX": " \\TeX \\ ",
"": "\\euro",
">": "$>$",
"<": "$<$"
}
ESCAPES = ("&", "{", "}", "%")
@register.filter
@stringfilter
def texify(value):
"""
escapes/replaces special character with appropriate latex commands
"""
tex_value = []
# escape special symbols
for char in value:
tex_value.append("%s" % ("\\%s" % char if char in ESCAPES else char))
tex_value = "".join(tex_value)
# replace symbols / words with latex commands
for key, value in REPLACEMENTS.items():
tex_value = tex_value.replace(key, value)
return "%s" % tex_value
......@@ -3,8 +3,10 @@ from django import template
register = template.Library()
def get_url_name(request): # Only one argument.
def get_url_name(request): # Only one argument.
"""Gets url_name"""
return resolve(request.path_info).url_name
register.filter("url_name", get_url_name)
\ No newline at end of file
register.filter("url_name", get_url_name)
{% load common %}
{% load tex %}
\documentclass[11pt]{article}
\usepackage[ngerman]{babel}
......@@ -125,7 +126,7 @@ Stand: {% now "j. F Y H:i" %}\\
{# Display badge (for cancellations) #} {# Display notice and new line #}
{% if sub.badge %}
\normalsize\badge{ {{ sub.badge }} }
{% endif %} \color{ {{c}}} \large\textit{ {{sub.text|default:""|safe}} } \\
{% endif %} \color{ {{c}}} \large\textit{ {{sub.text|default:""|safe|texify|safe}} } \\
{% endwith %}
{% endfor %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment