markdown_it.common.utils module

Utilities for parsing source text

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

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

markdown_it.common.utils.assign(obj)[源代码]

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

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

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[源代码]
markdown_it.common.utils.escapeRE(string: str) str[源代码]
markdown_it.common.utils.fromCodePoint(c: int) str[源代码]

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[源代码]

Markdown ASCII punctuation characters.

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

See http://spec.commonmark.org/0.15/#ascii-punctuation-character

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

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

Zs (unicode class) || [tfvrn]

markdown_it.common.utils.normalizeReference(string: str) str[源代码]

Helper to unify [reference labels].

markdown_it.common.utils.replaceEntityPattern(match: str, name: str) str[源代码]

Convert HTML entity patterns

https://www.google.com -> https%3A//www.google.com
markdown_it.common.utils.stripEscape(string: str) str[源代码]

Strip escape characters

markdown_it.common.utils.unescapeAll(string: str) str[源代码]
markdown_it.common.utils.unescapeMd(string: str) str[源代码]