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

Method before

markdown_it/ruler.py:128–150  ·  view source on GitHub ↗

Add new rule to chain before one with given name. :param beforeName: new rule will be added before this one. :param ruleName: new rule will be added before this one. :param fn: new rule function. :param options: new rule options (not mandatory). :raises: KeyE

(
        self,
        beforeName: str,
        ruleName: str,
        fn: RuleFuncTv,
        options: RuleOptionsType | None = None,
    )

Source from the content-addressed store, hash-verified

126 self.__cache__ = None
127
128 def before(
129 self,
130 beforeName: str,
131 ruleName: str,
132 fn: RuleFuncTv,
133 options: RuleOptionsType | None = None,
134 ) -> None:
135 """Add new rule to chain before one with given name.
136
137 :param beforeName: new rule will be added before this one.
138 :param ruleName: new rule will be added before this one.
139 :param fn: new rule function.
140 :param options: new rule options (not mandatory).
141 :raises: KeyError if name not found
142 """
143 index = self.__find__(beforeName)
144 options = options or {}
145 if index == -1:
146 raise KeyError(f"Parser rule not found: {beforeName}")
147 self.__rules__.insert(
148 index, Rule[RuleFuncTv](ruleName, True, fn, options.get("alt", []))
149 )
150 self.__cache__ = None
151
152 def after(
153 self,

Callers 3

_make_colon_fence_mdFunction · 0.80
_make_exact_mdMethod · 0.80
_pluginFunction · 0.80

Calls 1

__find__Method · 0.95

Tested by 3

_make_colon_fence_mdFunction · 0.64
_make_exact_mdMethod · 0.64
_pluginFunction · 0.64