fenced_code
Fenced Code Extension for Python Markdown.
This extension adds Fenced Code Blocks to Python-Markdown.
See https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html for documentation.
Original code Copyright 2007-2008 Waylan Limberg.
All changes Copyright 2008-2014 The Python Markdown Project
License: BSD
Classes
FencedCodeExtension(*args, **kwargs)
Bases: Extension
Fenced code extension.
Initiate Extension and set up configs.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/__init__.py
Attributes
config = {}
class-attribute
instance-attribute
Functions
getConfig(key, default='')
Return a setting for the given key or an empty string.
getConfigs()
getConfigInfo()
setConfig(key, value)
Set a config setting for key
with the given value
.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/__init__.py
setConfigs(items)
Set multiple config settings given a dict or list of tuples.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/__init__.py
extendMarkdown(md, md_globals)
Add FencedBlockPreprocessor to the Markdown instance.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/fenced_code.py
FencedBlockPreprocessor(md)
Bases: Preprocessor
Fenced code block preprocessor.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/fenced_code.py
Attributes
markdown = markdown_instance
instance-attribute
FENCED_BLOCK_RE = re.compile('\n(?P<fence>^(?:~{3,}|`{3,}))[ ]* # Opening ``` or ~~~\n(\\{?\\.?(?P<lang>[\\w#.+-]*))?[ ]* # Optional {, and lang\n# Optional highlight lines, single- or double-quote-delimited\n(hl_lines=(?P<quot>"|\')(?P<hl_lines>.*?)(?P=quot))?[ ]*\n}?[ ]*\\n # Optional closing }\n(?P<code>.*?)(?<=\\n)\n(?P=fence)[ ]*$', re.MULTILINE | re.DOTALL | re.VERBOSE)
class-attribute
instance-attribute
CODE_WRAP = '<pre><code%s>%s</code></pre>'
class-attribute
instance-attribute
LANG_TAG = ' class="%s"'
class-attribute
instance-attribute
checked_for_codehilite = False
instance-attribute
codehilite_conf = {}
instance-attribute
Functions
run(lines)
Match and store Fenced Code Blocks in the HtmlStash.