gfm.semi_sane_lists
– GitHub-like list parsing¶
The gfm.semi_sane_lists
module provides an extension that causes lists
to be treated the same way GitHub does.
Like the sane_lists
extension, GitHub considers a list to end if it’s
separated by multiple newlines from another list of a different type. Unlike
the sane_lists
extension, GitHub will mix list types if they’re not
separated by multiple newlines.
GitHub also recognizes lists that start in the middle of a paragraph. This is currently not supported by this extension, since the Python parser has a deeply-ingrained belief that blocks are always separated by multiple newlines.
Typical usage¶
import markdown
from gfm import SemiSaneListExtension
print(markdown.markdown("""
- eggs
- milk
1. mix
2. stew
""", extensions=[SemiSaneListExtension()]))
<ul>
<li>eggs</li>
<li>milk</li>
</ul>
<ol>
<li>mix</li>
<li>stew</li>
</ol>
-
class
gfm.semi_sane_lists.
SemiSaneListExtension
(*args, **kwargs)[source]¶ Bases:
markdown.extensions.Extension
An extension that causes lists to be treated the same way GitHub does.
-
getConfig
(key, default='')¶ Return a setting for the given key or an empty string.
-
getConfigInfo
()¶ Return all config descriptions as a list of tuples.
-
getConfigs
()¶ Return all configs settings as a dict.
-
setConfig
(key, value)¶ Set a config setting for key with the given value.
-
setConfigs
(items)¶ Set multiple config settings given a dict or list of tuples.
-