Debian Codegraph @

third_party/python/Mako/mako/ext/preprocessors.py

raw
1 # ext/preprocessors.py
2 # Copyright 2006-2022 the Mako authors and contributors <see AUTHORS file>
3 #
4 # This module is part of Mako and is released under
5 # the MIT License: http://www.opensource.org/licenses/mit-license.php
6
7 """preprocessing functions, used with the 'preprocessor'
8 argument on Template, TemplateLookup"""
9
10 import re
11
12
13 def convert_comments(text):
14 """preprocess old style comments.
15
16 example:
17
18 from mako.ext.preprocessors import convert_comments
19 t = Template(..., preprocessor=convert_comments)"""
20 return re.sub(r"(?<=\n)\s*#[^#]", "##", text)