Skip to content

Commit fe94b55

Browse files
committed
Allow parsing keyword argument to plugin loading
1 parent 5b26f76 commit fe94b55

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

markdown_it/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .main import MarkdownIt # noqa: F401
22

33

4-
__version__ = "0.2.2"
4+
__version__ = "0.2.3"

markdown_it/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def add_render_rule(self, name: str, function: Callable, fmt="html"):
189189
if self.renderer.__output__ == fmt:
190190
self.renderer.rules[name] = function.__get__(self.renderer)
191191

192-
def use(self, plugin: Callable, *params) -> "MarkdownIt":
192+
def use(self, plugin: Callable, *params, **options) -> "MarkdownIt":
193193
"""Load specified plugin with given params into current parser instance. (chainable)
194194
195195
It's just a sugar to call `plugin(md, params)` with curring.
@@ -201,7 +201,7 @@ def func(tokens, idx):
201201
md = MarkdownIt().use(plugin, 'foo_replace', 'text', func)
202202
203203
"""
204-
plugin(self, *params)
204+
plugin(self, *params, **options)
205205
return self
206206

207207
def parse(self, src: str, env: Optional[AttrDict] = None) -> List[Token]:

tests/test_math/test_math.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ def test_plugin_render():
110110
)
111111

112112

113+
def test_plugin_render_with_brackets():
114+
md = MarkdownIt().use(texmath_plugin, delimiters="brackets")
115+
text = md.render(r"\[a=1\]")
116+
assert text == ("<section><eqn>a=1</eqn></section>")
117+
118+
113119
@pytest.mark.parametrize(
114120
"index,comment,src,valid",
115121
[

0 commit comments

Comments
 (0)