markdown_it.common.utils module

Utilities for parsing source text

markdown_it.common.utils.arrayReplaceAt(src: list, pos: int, newElements: list)list[source]

Remove element from array and put another array at those position. Useful for some operations with tokens


Merge objects /from1, from2, from3, …/)

markdown_it.common.utils.charCodeAt(src: str, pos: int)Any[source]

Returns the Unicode value of the character at the specified location.

@param - index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

This was added for compatibility with python

markdown_it.common.utils.escapeHtml(raw: str)str[source]
markdown_it.common.utils.escapeRE(string: str)str[source]
markdown_it.common.utils.fromCodePoint(c: int)str[source]

Convert ordinal to unicode.

Note, in the original Javascript two string characters were required, for codepoints larger than 0xFFFF. But Python 3 can represent any unicode codepoint in one character.

markdown_it.common.utils.isMdAsciiPunct(ch: int)bool[source]

Markdown ASCII punctuation characters.

!, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~


Don’t confuse with unicode punctuation !!! It lacks some chars in ascii range.

markdown_it.common.utils.isPunctChar(ch: str)bool[source]
markdown_it.common.utils.isSpace(code: object)bool[source]
markdown_it.common.utils.isString(obj: object)bool[source]
markdown_it.common.utils.isValidEntityCode(c: int)bool[source]
markdown_it.common.utils.isWhiteSpace(code: int)bool[source]

Zs (unicode class) || [tfvrn]

markdown_it.common.utils.normalizeReference(string: str)str[source]

Helper to unify [reference labels].

markdown_it.common.utils.replaceEntityPattern(match: str, name: str)str[source]

Convert HTML entity patterns -> https%3A//
markdown_it.common.utils.stripEscape(string: str)str[source]

Strip escape characters

markdown_it.common.utils.unescapeAll(string: str)str[source]
markdown_it.common.utils.unescapeMd(string: str)str[source]