util
Markdown utils.
Attributes
PY3 = sys.version_info[0] == 3
module-attribute
string_type = str
module-attribute
text_type = str
module-attribute
int2str = chr
module-attribute
BLOCK_LEVEL_ELEMENTS = re.compile('^(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|hr|hr/|style|li|dt|dd|thead|tbody|tr|th|td|section|footer|header|group|figure|figcaption|aside|article|canvas|output|progress|video|nav|main)$', re.IGNORECASE)
module-attribute
STX = '\x02'
module-attribute
ETX = '\x03'
module-attribute
INLINE_PLACEHOLDER_PREFIX = STX + 'klzzwxh:'
module-attribute
INLINE_PLACEHOLDER = INLINE_PLACEHOLDER_PREFIX + '%s' + ETX
module-attribute
INLINE_PLACEHOLDER_RE = re.compile(INLINE_PLACEHOLDER % '([0-9]+)')
module-attribute
AMP_SUBSTITUTE = STX + 'amp' + ETX
module-attribute
HTML_PLACEHOLDER = STX + 'wzxhzdk:%s' + ETX
module-attribute
HTML_PLACEHOLDER_RE = re.compile(HTML_PLACEHOLDER % '([0-9]+)')
module-attribute
TAG_PLACEHOLDER = STX + 'hzzhzkh:%s' + ETX
module-attribute
Constants you probably do not need to change
RTL_BIDI_RANGES = (('\u0590', '߿'), ('ⴰ', '⵿'))
module-attribute
Classes
AtomicString
Bases: unicode
A string which should not be further processed.
Processor(markdown_instance=None)
HtmlStash()
Bases: object
HTML objects stash.
Create a HtmlStash.
Source code in pyrevitlib/pyrevit/coreutils/markdown/util.py
Attributes
html_counter = 0
instance-attribute
rawHtmlBlocks = []
instance-attribute
tag_counter = 0
instance-attribute
tag_data = []
instance-attribute
Functions
store(html, safe=False)
Saves an HTML segment for later reinsertion.
Returns a placeholder string that needs to be inserted into the document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
html |
str
|
an html segment |
required |
safe |
bool
|
label an html segment as safe for safemode |
False
|
Returns:
Type | Description |
---|---|
str
|
a placeholder string |
Source code in pyrevitlib/pyrevit/coreutils/markdown/util.py
reset()
get_placeholder(key)
store_tag(tag, attrs, left_index, right_index)
Store tag data and return a placeholder.
Source code in pyrevitlib/pyrevit/coreutils/markdown/util.py
Functions
isBlockLevel(tag)
Check if the tag is a block level HTML tag.
parseBoolValue(value, fail_on_errors=True, preserve_none=False)
Parses a string representing bool value.
If parsing was successful, returns True or False. If preserve_none=True, returns True, False, or None. If parsing was not successful, raises ValueError, or, if fail_on_errors=False, returns None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
String to parse. |
required |
fail_on_errors |
bool
|
If True, raises ValueError. |
True
|
preserve_none |
bool
|
If True and value is None, returns None. |
False
|
Returns:
Type | Description |
---|---|
bool
|
boolean value |