Conversation
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
=========================================
Coverage ? 96.24%
=========================================
Files ? 9
Lines ? 453
Branches ? 0
=========================================
Hits ? 436
Misses ? 17
Partials ? 0
Continue to review full report at Codecov.
|
682dcc4 to
eb1b05e
Compare
|
Hey, could you help me understand a few things. We already pass some state to the parser and render in the
Makes me think that the source of |
|
Also would be interested in how you plan to use this feature exactly? Is there a use case for |
The difference is that mdit = MarkdownIt()
# this option wil be used for every parse
mdit.option["a"] = 1
# but the env will only be used for the parse it is set on
mdit.parse("hallo", env={"b": 1})
mdit.parse("hallo")So yeh you are probably right that this data should update options. Note, mdformat anyhow diminishes this distinction a bit, because a new
Any way I want lol. mdit.use(texmath_plugin, delimiters="gitlab")I don't want to have to create a separate plugin for every style, over just calling something like mdit.use(texmath_plugin, delimiters=mdit.options.get("texmath-delim", "dollars")) |
|
In 0672535 I've moved to updating |
MarkdownIt instance
|
Thanks for the explanation!
Aha, if it's as general purpose as this, then what do you think about the following: we give plugins the possibility to add I think we'd need another function to the plugin interface, something like def add_options(parser: argparse.ArgumentParser) -> None:
...which is where a plugin would add its options. Then in import mdformat
options = vars(parser.parse_args(cli_args))
mdformat.text("bla bla", options=options) |
|
We could make defining What do you think? |
Yeh absolutely, I thought you'd be more willing to accept a simpler approach lol, but that is more of a "complete" solution 👍 |
I think these options should still be stored in mdit = MarkdownIt()
options = vars(parser.parse_args(cli_args))
mdit.options["mdformat"] = options |
Yeh thts what I have done in #36, for allowing plugins to specify certain HTML classes to ignore when comparing the input/output HTML |
I would use a top-level key too. Not sure, but perhaps even two keys, if we want to fit the current "codeformatters" and "parser_extensions" in the same top-level key. Something like: options["mdformat"]["opts"]
options["mdformat"]["codeformatters"]
options["mdformat"]["parser_extensions"] |
This provides a hook for passing variables to the parsing/render process, which in-turn provides a simple way of allowing plugins to accept variable arguments from the API or CLI .
7634a6e to
ee8a160
Compare
|
Looking very good! There's one unresolved comment I think you might have missed. |
|
yeh I just had to fix the test |
|
Beautiful, thanks! Merged |
This provides a hook for passing variables to the parsing/render process,
which in-turn provides a simple way of allowing plugins to accept variable arguments from the API or CLI.
Note this is back-incompatible for parser plugins, sinceupdate_mditnow also gets passed this env dict.