推荐学习书目
› 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
mulog
V2EX  ›  Python

问个解析 markdown 的问题

  •  
  •   mulog · Feb 20, 2014 · 3674 views
    This topic created in 4613 days ago, the information mentioned may be changed or developed.
    用markdown.markdown()来把markdown转换成html
    但是发现在转换code的时候 如果里面有空行 就不会转义成code标签
    比如
    str = """
    ```
    line

    another line
    ```
    """
    此时转换出的html就没有<code>标签了。把空的那行去掉则ok。
    (或者戳http://pythonfiddle.com/markdown-code-problem )

    我想问一下markdown是不允许```....```里的代码块有空行么?可是我找了几个在线的markdown编辑器都没问题的。 应该如何解决?
    4 replies  •  1970-01-01 08:00:00 +08:00
    jakwings
        1
    jakwings  
       Feb 20, 2014
    自行修改转换工具并提交建议?估计是表现不一致的 bug 。
    在 <pre> 里面,个人认为没必要加 <code> 标签,代码高亮工具一般不会管这些东西的吧?
    jakwings
        2
    jakwings  
       Feb 20, 2014
    这个转换工具比较特别,竟然是把所有东西都放进段落 <p> 里的……估计是实现的问题。假如栅栏式代码块都不支持空行,那还真的有问题了。建议换个转换工具。
    strak47
        3
    strak47  
       Feb 20, 2014
    如果把代码块改成像stackoverflow那样四个空格缩进呢,而不是 ``` 包围
    mulog
        4
    mulog  
    OP
       Feb 20, 2014
    @jakwings
    @strak47

    囧 最后发现要在使用一个"fenced_code"的extension之后才能完全支持代码块
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   912 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:45 · PVG 05:45 · LAX 14:45 · JFK 17:45
    ♥ Do have faith in what you're doing.