footnotes
Footnotes Extension for Python-Markdown.
Adds footnote handling to Python-Markdown.
See https://pythonhosted.org/Markdown/extensions/footnotes.html for documentation.
Copyright The Python Markdown Project
License: BSD
Attributes
FN_BACKLINK_TEXT = util.STX + 'zz1337820767766393qq' + util.ETX
module-attribute
NBSP_PLACEHOLDER = util.STX + 'qq3936677670287331zz' + util.ETX
module-attribute
DEF_RE = re.compile('[ ]{0,3}\\[\\^([^\\]]*)\\]:\\s*(.*)')
module-attribute
TABBED_RE = re.compile('((\\t)|( ))(.*)')
module-attribute
RE_REF_ID = re.compile('(fnref)(\\d+)')
module-attribute
Classes
FootnoteExtension(*args, **kwargs)
Bases: Extension
Footnote Extension.
Setup configs.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
Attributes
config = {'PLACE_MARKER': ['///Footnotes Go Here///', 'The text string that marks where the footnotes go'], 'UNIQUE_IDS': [False, 'Avoid name collisions across multiple calls to reset().'], 'BACKLINK_TEXT': ['↩', "The text string that links from the footnote to the reader's place."]}
instance-attribute
unique_prefix = 0
instance-attribute
found_refs = {}
instance-attribute
used_refs = set()
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 pieces to Markdown.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
reset()
Clear footnotes on reset, and prepare for distinct document.
unique_ref(reference, found=False)
Get a unique reference if there are duplicates.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
findFootnotesPlaceholder(root)
Return ElementTree Element that contains Footnote placeholder.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
setFootnote(id, text)
get_separator()
makeFootnoteId(id)
Return footnote link id.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
makeFootnoteRefId(id, found=False)
Return footnote back-link id.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
makeFootnotesDiv(root)
Return div of footnotes as et Element.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
FootnotePreprocessor(footnotes)
Bases: Preprocessor
Find all footnote references and store for later use.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
Attributes
markdown = markdown_instance
instance-attribute
footnotes = footnotes
instance-attribute
Functions
run(lines)
Loop through lines and find, set, and remove footnote definitions.
Keywords:
- lines: A list of lines of text
Return: A list of lines of text with footnote definitions removed.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
detectTabbed(lines)
Find indented text and remove indent before further proccesing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lines |
list[str]
|
text lines |
required |
Returns:
Type | Description |
---|---|
tuple[list, int]
|
post processed items and the index of last line. |
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
FootnotePattern(pattern, footnotes)
Bases: Pattern
InlinePattern for footnote markers in a document's body text.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
Attributes
pattern = pattern
instance-attribute
compiled_re = re.compile('^(.*?)%s(.*)$' % pattern, re.DOTALL | re.UNICODE)
instance-attribute
safe_mode = False
instance-attribute
markdown = markdown_instance
instance-attribute
footnotes = footnotes
instance-attribute
Functions
getCompiledRegExp()
type()
unescape(text)
Return unescaped text given text with an inline placeholder.
Source code in pyrevitlib/pyrevit/coreutils/markdown/inlinepatterns.py
handleMatch(m)
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
FootnotePostTreeprocessor(footnotes)
Bases: Treeprocessor
Ammend footnote div with duplicates.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
Attributes
markdown = markdown_instance
instance-attribute
footnotes = footnotes
instance-attribute
Functions
add_duplicates(li, duplicates)
Adjust current li and add the duplicates: fnref2, fnref3, etc.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
get_num_duplicates(li)
Get the number of duplicate refs of the footnote.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
handle_duplicates(parent)
Find duplicate footnotes and format and add the duplicates.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
run(root)
Crawl the footnote div and add missing duplicate footnotes.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
FootnoteTreeprocessor(footnotes)
Bases: Treeprocessor
Build and append footnote div to end of document.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
Attributes
markdown = markdown_instance
instance-attribute
footnotes = footnotes
instance-attribute
Functions
run(root)
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/footnotes.py
FootnotePostprocessor(footnotes)
Bases: Postprocessor
Replace placeholders with html entities.