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

Method __init__

markdown_it/parser_inline.py:99–112  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

97
98class ParserInline:
99 def __init__(self) -> None:
100 self.ruler = Ruler[RuleFuncInlineType]()
101 for name, rule in _rules:
102 self.ruler.push(name, rule)
103 # Second ruler used for post-processing (e.g. in emphasis-like rules)
104 self.ruler2 = Ruler[RuleFuncInline2Type]()
105 for name, rule2 in _rules2:
106 self.ruler2.push(name, rule2)
107 # Characters that stop the text rule, allowing other inline rules to fire.
108 # _extra_terminator_chars is only allocated when add_terminator_char() is called
109 # with a char outside the defaults, keeping __init__ allocation-free.
110 self._extra_terminator_chars: set[str] = set()
111 # Pre-compiled regex shared with all default instances (no copy in the common path).
112 self.terminator_re: re.Pattern[str] = _default_terminator_re()
113
114 def add_terminator_char(self, ch: str) -> None:
115 """Register a character that stops the ``text`` rule, allowing inline rules to fire.

Callers

nothing calls this directly

Calls 2

_default_terminator_reFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected