-
Notifications
You must be signed in to change notification settings - Fork 49
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
mdformat breaks Hugo shortcodes by escaping <
#402
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as spam.
This comment was marked as spam.
remove because of hukkin/mdformat#402
* mark jobs as failed on restart * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test the startup db functions * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update README.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove mdformater remove because of hukkin/mdformat#402 * Update README.md --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Fabian Zills <46721498+PythonFZ@users.noreply.github.com>
It would be really nice to have support for turning off this escape option. Is there any progress on this? I've also added an issue on snippets to support this via a plugin, but it'd be great to have more control in mdformat directly. |
Hey, thanks for the issue! Mdformat is a CommonMark formatter. It doesn't support Hugo, mkdocs, GitHub etc. extensions out of the box. The syntax it does support is listed here https://spec.commonmark.org/0.29/ There is plugin API that can be used to extend the syntax. For mkdocs there is
There is really no "escape option" to turn off. We need the escapes to make sure our formatting changes do not change Markdown "AST". There is an issue for reducing the occasions where escapes are necessary #112 |
For those looking for a work-around, I found one that works at least in my case. I don't love it but it enabled me to move on. Surrounding the shortcode with an inline code block prevents mdformat from escaping anything inside it. The surprising thing to me is the precedence of the shortcode is apparently higher than the precedence of the code block. The side-effect is that there is an empty
|
Describe the bug
context
Running
mdformat
on a Markdown file with a Hugo shortcode.expectation
I expected
mdformat
to not break the shortcode.bug
Instead
mdformat
is breaking the shortcode by escaping<
to\<
.problem
This breaks the shortcode for Hugo users.
Relevant Hugo comment: #112 (comment)
Reproduce the bug
That links to this YouTube video.
mdformat
corrects this to{{\< youtube -dJolYw8tnk >}}
List your environment
The text was updated successfully, but these errors were encountered: