推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
cc7756789
V2EX  ›  Python

Python flask 使用 markdown 出现问题

  •  
  •   cc7756789 · Jun 19, 2015 · 4189 views
    This topic created in 3979 days ago, the information mentioned may be changed or developed.

    以下为数据库中的markdown
    img

    然后通过:

    import markdown
    markdown.markdown(content)
    

    就变成这样的了
    exception

    而且发现由于有<a name=''> 标签没有关闭会干扰到其他HTML,这种该怎么解决?

    5 replies    2015-06-19 09:12:34 +08:00
    zhuangzhuang1988
        1
    zhuangzhuang1988  
       Jun 19, 2015
    不要内嵌<a>, 用 markdown语法 [This link](http://example.net/) has no title attribute.
    ccbikai
        2
    ccbikai  
    PRO
       Jun 19, 2015
    关闭一下 a 标签 不就好了
    Septembers
        3
    Septembers  
       Jun 19, 2015 via Android
    HTML不闭合标签会有各种意想不到的问题
    v2gba
        4
    v2gba  
       Jun 19, 2015
    如果markdown是你提供的, 不要这么写
    如果markdown你无法控制, 但不在乎是否保留html标签
    可以:
    markdown(untrusted, safe_mode=remove, enable_attributes=False)
    如果*, 而且*,
    自己写parser
    elvis_w
        5
    elvis_w  
       Jun 19, 2015
    flask不是有现成的markdown插件吗
    https://pythonhosted.org/Flask-Markdown/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1069 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 18:41 · PVG 02:41 · LAX 11:41 · JFK 14:41
    ♥ Do have faith in what you're doing.