MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / push

Method push

markdown_it/rules_inline/state_inline.py:92–119  ·  view source on GitHub ↗

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

(self, ttype: str, tag: str, nesting: Literal[-1, 0, 1])

Source from the content-addressed store, hash-verified

90 return token
91
92 def push(self, ttype: str, tag: str, nesting: Literal[-1, 0, 1]) -> Token:
93 """Push new token to "stream".
94 If pending text exists - flush it as text token
95 """
96 if self.pending:
97 self.pushPending()
98
99 token = Token(ttype, tag, nesting)
100 token_meta = None
101
102 if nesting < 0:
103 # closing tag
104 self.level -= 1
105 self.delimiters = self._prev_delimiters.pop()
106
107 token.level = self.level
108
109 if nesting > 0:
110 # opening tag
111 self.level += 1
112 self._prev_delimiters.append(self.delimiters)
113 self.delimiters = []
114 token_meta = {"delimiters": self.delimiters}
115
116 self.pendingLevel = self.level
117 self.tokens.append(token)
118 self.tokens_meta.append(token_meta)
119 return token
120
121 def scanDelims(self, start: int, canSplitWord: bool) -> Scanned:
122 """

Callers 11

tokenizeFunction · 0.45
autolinkFunction · 0.45
imageFunction · 0.45
linkFunction · 0.45
linkifyFunction · 0.45
html_inlineFunction · 0.45
escapeFunction · 0.45
tokenizeFunction · 0.45
backtickFunction · 0.45
newlineFunction · 0.45
entityFunction · 0.45

Calls 2

pushPendingMethod · 0.95
TokenClass · 0.85

Tested by

no test coverage detected