Skip to content
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

Enable a default set of mistune2 plugins for feature parity with mistune0 #1074

Merged
merged 2 commits into from Sep 28, 2022

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Sep 21, 2022

The features provided by the mistune2 plugins url, strikethrough, footnotes, and table provide features which were supported by mistune 0.8.4 out of the box.

For the sake of backwards-compatibility, since these features were all supported by older versions of Lektor (due to use of mistune 0.x) we should enable these plugins by default when running with mistune2.

This PR does that.

Issue(s) Resolved

When using mistune >= 2, markdown features which were previously supported under mistune 0.x are disabled by default.

Related Issues / Links

This builds upon the work to support mistune 2 in PR #992.

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)

… by default

These plugins provide features which are provided by mistune 0.8.4 and
were therefore available in previous versions of Lektor.  We enable
them by default for the sake of backwards-compatibility.
@nixjdm
Copy link
Member

nixjdm commented Sep 21, 2022

This is great.

Also, the test is the only Lektor plugin I can recall that uses on_markdown_lexer_config. I think it's worth adding a mention of it to the docs https://www.getlektor.com/docs/api/plugins/events/markdown-lexer-config/

@dairiki
Copy link
Contributor Author

dairiki commented Sep 21, 2022

Also, the test is the only Lektor plugin I can recall that uses on_markdown_lexer_config. I think it's worth adding a mention of it to the docs https://www.getlektor.com/docs/api/plugins/events/markdown-lexer-config/

The test could just as well have used on_markdown_config in this case.

I'm not quite sure myself what the exact purpose of on_markdown_lexer_config is. The only real distinction distinction between the two is that on_markdown_lexer_config has access to the renderer instance, while on_markdown_config does not (since it is called before the renderer is constructed).

@nixjdm
Copy link
Member

nixjdm commented Sep 21, 2022

The test could just as well have used on_markdown_config in this case.

Ah, I see. Yeah, then I can't recall ever seeing a use of on_markdown_lexer_config.

I suppose someone could modify the render after it's created to add methods to it after creation. Perhaps that might seem more natural than customizing the markdown config and improved renderer that we have. That seems less explicit though, and maybe should be discouraged, in favor of supplying an explicitly made renderer to the config. Also off topic for this PR I suppose.

Attempt to protect against configuring duplicate plugins.
@dairiki dairiki merged commit 4ad75dd into lektor:master Sep 28, 2022
@dairiki dairiki deleted the bug.mistune-feature-parity branch March 3, 2023 20:35
dairiki added a commit to dairiki/lektor that referenced this pull request Sep 11, 2023
…une0 (lektor#1074)

* mistune2: Enable the url, strikethrough, footnotes, and table plugins by default

These plugins provide features which are provided by mistune 0.8.4 and
were therefore available in previous versions of Lektor.  We enable
them by default for the sake of backwards-compatibility.

Support specifying external plugins using "module.name:attr" syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants