from jinja2.utils import Markup from jinja2._compat import text_type import re def do_stringtags_and_img(value): """ Strip SGML/XML tags and replace adjacent whitespace by one space. """ if hasattr(value, '__html__'): value = value.__html__() no_img_part = re.sub(r']+?', "", value) return Markup(text_type(no_img_part)).striptags() def sidebar(value): value = '%s' % value if value.startswith('archives') or value.startswith('category'): return 'right-sidebar' elif value == 'index': return 'index' else: return 'no-sidebar'