Added the possibility to pass a macro filter to the render methods

This commit is contained in:
Dirk Alders 2024-10-05 20:16:30 +02:00
parent 8a2da2b843
commit 2abea3c4ae

View File

@ -22,11 +22,11 @@ def mycreole_help_pagecontent():
return creole.creole2html(MYCREOLE_HELP) return creole.creole2html(MYCREOLE_HELP)
def render_simple(text): def render_simple(text, macros=None):
return creole.creole2html(text) return creole.creole2html(text, macros=macros)
def render(request, text, attachment_target_path, next_anchor=''): def render(request, text, attachment_target_path, next_anchor='', macros=None):
def get_attachment_name(text, state): def get_attachment_name(text, state):
end_idx = text.index(']]' if state == '[' else '}}') end_idx = text.index(']]' if state == '[' else '}}')
try: try:
@ -84,9 +84,9 @@ def render(request, text, attachment_target_path, next_anchor=''):
else: else:
render_txt += '[[%s|Upload]]' % url_upload(request, rel_path, next_anchor) render_txt += '[[%s|Upload]]' % url_upload(request, rel_path, next_anchor)
text = text[text.index(']]' if state == '[' else '}}') + 2:] text = text[text.index(']]' if state == '[' else '}}') + 2:]
return creole.creole2html(render_txt) return creole.creole2html(render_txt, macros=macros)
except: except:
return creole.creole2html(text) return creole.creole2html(text, macros=macros)
def url_delete(request, rel_path, next_anchor=''): def url_delete(request, rel_path, next_anchor=''):