开源软件名称(OpenSource Name):trentm/python-markdown2开源软件地址(OpenSource Url):https://github.com/trentm/python-markdown2开源编程语言(OpenSource Language):Python 54.1%开源软件介绍(OpenSource Introduction):Markdown is a light text markup format and a processor to convert that to HTML. The originator describes it as follows:
This (markdown2) is a fast and complete Python implementation of Markdown. It was written to closely match the behaviour of the original Perl-implemented Markdown.pl. Markdown2 also comes with a number of extensions (called "extras") for things like syntax coloring, tables, header-ids. See the "Extra Syntax" section below. "markdown2" supports all Python versions 3.5+ (and pypy and jython, though I don't frequently test those). There is another Python markdown.py. However, at least at the time this project was started, markdown2.py was faster (see the Performance Notes) and, to my knowledge, more correct (see Testing Notes). That was a while ago though, so you shouldn't discount Python-markdown from your consideration. Follow @trentmick for updates to python-markdown2. InstallTo install it in your Python installation run one of the following:
However, everything you need to run this is in "lib/markdown2.py". If it is easier for you, you can just copy that file to somewhere on your PythonPath (to use as a module) or executable path (to use as a script). Quick UsageAs a module: >>> import markdown2
>>> markdown2.markdown("*boo!*") # or use `html = markdown_path(PATH)`
'<p><em>boo!</em></p>\n'
>>> from markdown2 import Markdown
>>> markdowner = Markdown()
>>> markdowner.convert("*boo!*")
'<p><em>boo!</em></p>\n'
>>> markdowner.convert("**boom!**")
'<p><strong>boom!</strong></p>\n' As a script (CLI): $ python markdown2.py foo.md > foo.html or $ python -m markdown2 foo.md > foo.html I think pip-based installation will enable this as well: $ markdown2 foo.md > foo.html See the project wiki,
lib/markdown2.py
docstrings and/or Extra Syntax (aka extensions)Many Markdown processors include support for additional optional syntax (often called "extensions") and markdown2 is no exception. With markdown2 these are called "extras". Using the "footnotes" extra as an example, here is how you use an extra ... as a module: $ python markdown2.py --extras footnotes foo.md > foo.html as a script: >>> import markdown2
>>> markdown2.markdown("*boo!*", extras=["footnotes"])
'<p><em>boo!</em></p>\n' There are a number of currently implemented extras for tables, footnotes,
syntax coloring of ProjectThe python-markdown2 project lives at https://github.com/trentm/python-markdown2/. (Note: On Mar 6, 2011 this project was moved from Google Code to here on Github.) See also, markdown2 on the Python Package Index (PyPI). The change log: https://github.com/trentm/python-markdown2/blob/master/CHANGES.md To report a bug: https://github.com/trentm/python-markdown2/issues ContributingWe welcome pull requests from the community. Please take a look at the TODO for opportunities to help this project. For those wishing to submit a pull request to
Test SuiteThis markdown implementation passes a fairly extensive test suite. To run it: make test The crux of the test suite is a number of "cases" directories -- each with a set of matching .text (input) and .html (expected output) files. These are:
See the Testing Notes wiki page for full details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论