markdown_it.rules_inline.state_inline module#

class markdown_it.rules_inline.state_inline.Delimiter(marker: 'int', length: 'int', token: 'int', end: 'int', open: 'bool', close: 'bool', level: 'bool | None' = None)[source]#

Bases: object

close: bool#
end: int#
length: int#
level: bool | None#
marker: int#
open: bool#
token: int#
class markdown_it.rules_inline.state_inline.Scanned(can_open, can_close, length)[source]#

Bases: NamedTuple

can_close: bool#

Alias for field number 1

can_open: bool#

Alias for field number 0

length: int#

Alias for field number 2

class markdown_it.rules_inline.state_inline.StateInline(src: str, md: MarkdownIt, env: EnvType, outTokens: list[Token])[source]#

Bases: StateBase

append_pending(text: str) → None[source]#

Append literal text to pending, in amortised O(1) time.

Prefer this to state.pending += text on hot paths: it buffers the fragment rather than rebuilding the whole pending string per call.

html_terminator_last(term: str) → int[source]#

Index of the last occurrence of term in self.src, or -1.

The result is cached per terminator, for the life of the state. It is used by the html_inline rule to reject, in constant time, a position at which the terminator required to close an HTML construct cannot possibly occur – without running the tag regex, whose lazy sub-patterns would otherwise rescan to the end of the input on every such (failing) attempt.

property pending: str#

Literal text accumulated so far, but not yet flushed to a token.

push(ttype: str, tag: str, nesting: Literal[-1, 0, 1]) → Token[source]#

Push new token to “stream”. If pending text exists - flush it as text token

pushPending() → Token[source]#
scanDelims(start: int, canSplitWord: bool) → Scanned[source]#

Scan a sequence of emphasis-like markers, and determine whether it can start an emphasis sequence or end an emphasis sequence.

  • start - position to scan from (it should point at a valid marker);

  • canSplitWord - determine if these markers can be found inside a word