MarkDown 的 python 实现:Python-Markdown
jopen
10年前
MarkDown 的 python 实现。这几乎是完全符合规范的实现,但也有一些非常细微的差别。
除了基本的Markdown语法,Python-Markdown支持以下功能:
-
International Input
Python-Markdown will accept input in any language supported by Unicode including bi-directional text. In fact the test suite includes documents written in Russian and Arabic.
-
Extensions
Various extensions are provided (including extra) to change and/or extend the base syntax. Additionally, a public Extension API is available to write your own extensions.
-
Output Formats
Python-Markdown can output documents in HTML4, XHTML and HTML5. See theLibrary Reference for details.
-
Command Line Interface
In addition to being a Python Library, a command line script is available for your convenience.
示例代码:
import markdown import bleach html = bleach.clean(markdown.markdown(untrusted_text)) md = markdown.Markdown(safe_mode='replace', html_replacement_text='--RAW HTML NOT ALLOWED--')