Skip to content
Snippets Groups Projects
Select Git revision
  • e47ccaeb2622c62d811a36757e9a22da03e033ad
  • main default protected
  • feature/export-filtering
  • feature/clear-schedule-button
  • fix/responsive-cols-in-polls
  • feature/preference-polling-form
  • feature/json-export-via-rest-framework
  • feature/json-schedule-import-tests
  • fix/add-room-import-only-once
  • ak-import
  • renovate/django-simple-history-3.x
  • renovate/django-debug-toolbar-4.x
  • renovate/django-5.x
  • renovate/mysqlclient-2.x
14 results

tests.py

Blame
  • Forked from KIF / AKPlanning
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    environment.py 967 B
    # environment.py
    import re
    
    from django_tex.environment import environment
    
    # Used to filter all very special UTF-8 chars that are probably not contained in the LaTeX fonts
    # and would hence cause compilation errors
    utf8_replace_pattern = re.compile(u'[^\u0000-\u206F]', re.UNICODE)
    
    
    def latex_escape_utf8(value):
        """
        Escape latex special chars and remove invalid utf-8 values
    
        :param value: string to escape
        :type value: str
        :return: escaped string
        :rtype: str
        """
        return utf8_replace_pattern.sub('', value).replace('&', '\&').replace('_', '\_').replace('#', '\#').replace('$',
                                                                                                                    '\$').replace(
            '%', '\%').replace('{', '\{').replace('}', '\}')
    
    
    def improved_tex_environment(**options):
        env = environment(**options)
        env.filters.update({
            'latex_escape_utf8': latex_escape_utf8,
        })
        return env