views.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Startup-Fairy 作者: cs373gc-fall-2016 项目源码 文件源码
def parse_markdown():
    text = request.args.get('text')
    if text is None:
        abort(404)
    highlight = request.args.get('word')
    if highlight is not None:
        text = text.replace(highlight, '**' + highlight + '**')
    # Anything that isn't a square closing bracket
    name_regex = "[^]]+"
    # http:// or https:// followed by anything but a closing paren
    url_regex = "http[s]?://[^)]+"

    markup_regex = '\[({0})]\(\s*({1})\s*\)'.format(name_regex, url_regex)

    for match in re.findall(markup_regex, text):
        print(match)
        print(match[0])
        print(match[1])
        text = text.replace("[" + match[0] + "](" + match[1] + ")", match[0])
    processed = markdown2.markdown(text)
    return json.dumps({"result": processed})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号