markdown_it.common.utils module#
Utilities for parsing source text
- markdown_it.common.utils.arrayReplaceAt(src: list[_ItemTV], pos: int, newElements: list[_ItemTV]) list[_ItemTV] [source]#
Remove element from array and put another array at those position. Useful for some operations with tokens
- markdown_it.common.utils.charCodeAt(src: str, pos: int) int | None [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.charStrAt(src: str, pos: int) str | None [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]#
Replace special characters “&”, “<”, “>” and ‘”’ to HTML-safe sequences.
- 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 ~
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 [source]#
Check if character is a punctuation character.
- markdown_it.common.utils.isSpace(code: int | None) bool [source]#
Check if character code is a whitespace.
- markdown_it.common.utils.isStrSpace(ch: str | None) bool [source]#
Check if character is a whitespace.
- markdown_it.common.utils.normalizeReference(string: str) str [source]#
Helper to unify [reference labels].