yibin001
V2EX  ›  问与答

Python下面的Markdown2在放代码时不能自动换行

  •  
  •   yibin001 · Jun 20, 2013 · 5864 views
    This topic created in 4804 days ago, the information mentioned may be changed or developed.
    在用python的Markdown2包,在转换时发现无法将代码块做换行处理,
    比如
    ```
    def test():
    pass
    ```

    最终生成的HTML代码是
    <code>def test():
    pass</code>
    这样代码就连到一行了,怎么处理?
    不会是要改源代码吧
    11 replies    1970-01-01 08:00:00 +08:00
    yuelang85
        1
    yuelang85  
       Jun 20, 2013
    代码块应该用缩进四个空格吧
    detailyang
        2
    detailyang  
       Jun 20, 2013
    你这个不是gitpage的markdown吗 - -
    yibin001
        3
    yibin001  
    OP
       Jun 20, 2013
    @yuelang85
    试了一下,4个空格也不行。。。。
    swulling
        4
    swulling  
       Jun 20, 2013
    这个不是标准Markdown语法
    yibin001
        5
    yibin001  
    OP
       Jun 20, 2013
    https://github.com/yibin001/python-markdown2
    用的是这个包,还有其它滴?
    yuelang85
        6
    yuelang85  
       Jun 20, 2013
    yibin001
        7
    yibin001  
    OP
       Jun 20, 2013
    @yuelang85
    Thank you,我试试
    yangzh
        8
    yangzh  
       Jun 20, 2013
    使用 http://misaka.61924.nl/api/ ,强烈推荐。

    这里有 github favoured markdown 的实现:https://gist.github.com/fyears/5097469
    yibin001
        9
    yibin001  
    OP
       Jun 20, 2013
    @yangzh
    看起来不错,不过本地通过pip安装后,包去哪了?我怎么传到服务器上?(服务器是无法pip的)
    yangzh
        10
    yangzh  
       Jun 20, 2013
    @yibin001 /usr/local/lib/python2.7/dist-packages

    服务器是 vps 的话应该可以非 root 用户安装 pip 的。
    tsinglux
        11
    tsinglux  
       Jun 20, 2013
    @yibin001 包在$pythonpath/site-packages/下面,无法pip那么可以上传上去源码setup啊,不过要自行解决依赖问题啊。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2883 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:51 · PVG 17:51 · LAX 02:51 · JFK 05:51
    ♥ Do have faith in what you're doing.