-
Notifications
You must be signed in to change notification settings - Fork 8
👌 IMPROVE: Alternative proposal for allowing colon fences #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
👌 IMPROVE: Alternative proposal for allowing colon fences #48
Conversation
df6eb7b to
4b3ff3a
Compare
|
@KyleKing are you still the right person to review this? Sorry for the inbox-blast if not (and please let me know if there's a better comms channel than just GitHub comments for this)! |
|
Great; thank you @brunobeltran for taking over ;-) |
KyleKing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments and overall looks like this should work with some caveats on performance. Thanks!
| :::{tip} Nested tip in list item | ||
| Tip content inside a list item. | ||
| ::: | ||
| . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not already added, can you make sure that other edge cases are tested? For example: with an empty directive, with arguments, containing a code block and deeper nesting, and maybe one to test that regular content with ::: is handled
Additionally, are any tests from #36 not covered here?
| return text | ||
|
|
||
|
|
||
| CHANGES_AST = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this strictly necessary? Turning this on can introduce a lot of risk -- I'm assuming this is required to deal with the recursion?
| plugin = mdformat.plugins.PARSER_EXTENSIONS[plugin_name] | ||
| if plugin not in mdit.options["parser_extension"]: | ||
| mdit.options["parser_extension"].append(plugin) | ||
| plugin.update_mdit(mdit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🌟
| formatted += mdformat.text( | ||
| content, options=context.options, extensions=extension_names | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little worried about this the performance here and would prefer to have native support like regex parsing (proposed in #36), but directive content should be small and is something we could revisit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bigger issue is that I don't think any other plugin uses mdformat recursively like this, so it could lead to unexpected behavior
An alternative proposal to #36 (fixes #13, thanks @nthiery for your pass at this, which inspired me to give it a shot).
Avoids the need for an explicit list of "container_names" (which doesn't seem like an appropriate thing for mdformat_myst to manage) by instead recursively calling mdformat's API directly. I'm not sure if there are any negative consequences to this, as I'm not very knowledgable on the mdformat codebase, but it doesn't seem to lead to a performance regression on $DAY_JOB's monorepo, at least.
Note that this PR also proposes a very noticeably different set of semantics for when to add padding newlines, namely: I only add padding newlines around child colon fences, so "regular" (e.g. paragraph) content does not get additional padding, maintaining more similarity with the current behavior.