各种 Markdown Parsers - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
lepture
V2EX    Python

各种 Markdown Parsers

  •  
  •   lepture
    lepture 2014-03-19 19:50:49 +08:00 4999 次点击
    这是一个创建于 4229 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这是我写的一篇介绍 Python 里的 Markdown Parser 的文章:

    http://lepture.com/en/2014/markdown-parsers-in-python

    列举了

    * Misaka: A python binding for Sundown. (CPython required)
    * Hoedown: A python binding for Hoedown, successor of Misaka.
    * Discount: A python binding for Discount. (CPython required)
    * cMarkdown: Markdown for Python, accelerated by C. (CPython required)
    * Markdown: A pure markdown parser, the very first implementation.
    * Markdown2: Another pure markdown parser.
    * Mistune: The fastest markdown parser in pure Python.

    其中要说明的是许多人被 Markdown2 骗了,这个号称 fast 的解析器是效率最低的。详情见我做的 benchmark: https://github.com/lepture/mistune/issues/1
    12 条回复    2014-07-03 15:44:50 +08:00
    yinian1992
        1
    yinian1992  
       2014-03-20 08:36:58 +08:00 via Android
    但是 markdown2 的 readme 上也写了 “That was a while ago though, so you shouldn't discount Python-markdown from your consideration.”
    我觉得 markdown2 最大的问题是扩展起来太 dirty 了。
    zqqf16
        2
    zqqf16  
       2014-03-20 08:39:34 +08:00
    俺当年也被骗了,直到后来发现Markdown2对多行代码的支持不太好才放弃了~
    soli
        3
    soli  
       2014-03-20 09:08:54 +08:00
    好像 Mou 用的就是 Discount 。 Discount 真的那么不堪么?
    housne
        4
    housne  
       2014-03-20 09:26:02 +08:00
    If you are on a Windows, may god helps you. I don't care it a shit. lol
    lepture
        5
    lepture  
    OP
       2014-03-20 09:48:59 +08:00
    @yinian1992 我目前最喜欢的是 renderer 方案。因为语法几乎不用扩展,需要修改的一般是渲染效果。
    lepture
        6
    lepture  
    OP
       2014-03-20 09:49:56 +08:00
    @soli 我文章里说的是 Discount 的 Python Binding。因为这货压根就没法安装。
    soli
        7
    soli  
       2014-03-20 09:54:46 +08:00
    @lepture 期待一个所有语言的 Markdown parser 评测。
    lepture
        8
    lepture  
    OP
       2014-03-20 10:11:14 +08:00
    @soli 没有必要测所有语言,如果是测速度的话,只用测 C 就好了。
    yinian1992
        9
    yinian1992  
       2014-03-20 12:26:16 +08:00
    @lepture 最后发现,要不还是用 rst 吧,md 感觉像是半成品。
    lepture
        10
    lepture  
    OP
       2014-03-20 15:04:05 +08:00
    @yinian1992 目的不同

    > Markdown is a text-to-HTML conversion tool for web writers.

    它本来就不是为写文档设计的。

    http://lepture.com/zh/2013/typography-and-markdown
    walnutist
        11
    walnutist  
       2014-03-25 11:57:39 +08:00
    我最近折腾了一遍Markdown Parser,Python的这些Parser后来全被我毙了,最终决定使用这个
    https://github.com/evilstreak/markdown-js

    我在选型过程中主要考虑的因素是:
    1、高度可扩展。我要的不是单纯标准的Markdown,更像是Markdown-like。Markdown本身还是太过geek。
    2、前后端Parser功能上一致
    3、可以轻松toHTML, toText, toPDF....
    4、Parser应该相对成熟和稳定

    最终让我下定决心选择markdown-js的因素,也是因为discourse用了这个框架,在discourse的代码中有很好的扩展实例。

    解析速度不是我关心的重点,因为我的app架构是后端node.js透过rest提供markdown-to-html服务,并直接在redis中缓存结果。
    lepture
        12
    lepture  
    OP
       2014-07-03 15:44:50 +08:00
    @walnutist Javascript 的明是 https://github.com/chjj/marked 要好很多。不是最快的,也是最容易懂代的,也是最容易展的。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2366 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 15:54 PVG 23:54 LAX 08:54 JFK 11:54
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86