示例#1
0
文件: pur.py 项目: Cloudef/PUR
def replace_recipe(expr, start, end, data):
    '''replace recipe block found by iter_callback'''
    recipe = expr.group(1)
    if RECIPEMANAGER.get_recipe(recipe):
        return replace.replace_range(data, start, end, replace.html_link('/recipe/{}'.format(recipe), recipe))
    return data
示例#2
0
文件: pur.py 项目: Cloudef/PUR
 def replace_urltable(expr, start, end, data):
     '''replace data from urltable'''
     parse = expr.group(1).split(':')
     if parse and parse[0] in MLURLTABLE:
         data = replace.replace_range(data, start, end, '<a href="{}">{}</a>'.format(MLURLTABLE[parse[0]], parse[1]))
     return data
示例#3
0
文件: pur.py 项目: Cloudef/PUR
def replace_togglable_code(expr, start, end, data):
    '''replace code block found by iter_callback'''
    lang = expr.group(1)
    code = expr.group(2)
    header = '{} {}'.format(lang, _('code')) if lang else _('Code')
    return replace.replace_range(data, start, end, '</pre>{}<pre>'.format(js_togglable(header, replace.syntax(code, lang), hidden=True)))