1# ext/preprocessors.py 2# Copyright 2006-2023 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' 8argument on Template, TemplateLookup""" 9 10import re 11 12 13def 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) 21