这是一个创建于 3865 天前的主题,其中的信息可能已经有所发展或是发生改变。
用markdown.markdown()来把markdown转换成html
但是发现在转换code的时候 如果里面有空行 就不会转义成code标签
比如
str = """
```
line
another line
```
"""
此时转换出的html就没有<code>标签了。把空的那行去掉则ok。
(或者戳http://pythonfiddle.com/markdown-code-problem )
我想问一下markdown是不允许```....```里的代码块有空行么?可是我找了几个在线的markdown编辑器都没问题的。 应该如何解决?
4 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
jakwings 2014-02-20 11:16:58 +08:00
自行修改转换工具并提交建议?估计是表现不一致的 bug 。 在 <pre> 里面,个人认为没必要加 <code> 标签,代码高亮工具一般不会管这些东西的吧?
|
|
|
2
jakwings 2014-02-20 11:22:24 +08:00
这个转换工具比较特别,竟然是把所有东西都放进段落 <p> 里的……估计是实现的问题。假如栅栏式代码块都不支持空行,那还真的有问题了。建议换个转换工具。
|
|
|
3
strak47 2014-02-20 13:45:47 +08:00
如果把代码块改成像stackoverflow那样四个空格缩进呢,而不是 ``` 包围
|
|
|
4
mulog 2014-02-20 14:01:15 +08:00
@ jakwings @ strak47 囧 最后发现要在使用一个"fenced_code"的extension之后才能完全支持代码块
|