markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD033 : Hugo shortcode support

Open mysiki opened this issue 5 months ago • 3 comments

Hello,

I have an issue with the Rules MD033 : No inline HTML.

I use Hugo to generate my website, and Hugo allow to use shortcode (which generate HTML result). Shortcode can be call with different method : {{% shortcode %}} or {{< shortcode >}}. (https://gohugo.io/content-management/shortcodes/#notation)

Inside this shortcode, you can define some parameters. And I need to provide argument with "<" inside.

Test code :

bla bla 

- MY_VARIABLE: {{< shortcode pattern="<variable>" >}}

It's "strange" because the rule fire on pattern="<variable>" but not on {{<. It can work by escaping like '<' but this make the content more complex for no reason.

I try to check the code, but so far than what I know 😅...

Did you see a way to make the rule work ? Basically, {{% %}} and {{< >}} should not be considered as html elements. Maybe not as global rule, I'm not sure that this rule should work in no-Hugo site.

Maybe by using allowed_elements or improving the new table_allowed_elements to make something like "allow html inside this content" or a new switch special Hugo.

At the end, I don't know why this {{< do not fire the rule, it's maybe the start point :D.

Thanks for your help

mysiki avatar Jun 07 '25 06:06 mysiki

I'm not sure that this rule should work in no-Hugo site

Assuming there is a typo there, I agree that this rule does not seem appropriate for Hugo syntax. I would suggest disabling the rule for your project or maybe just for files that use that feature.

If Hugo supports directive syntax instead, you should be able to convert to that because it is recognized by the micromark parser: https://github.com/micromark/micromark-extension-directive

DavidAnson avatar Jun 07 '25 16:06 DavidAnson

Thinking more about that, and look like the problem is rule which is not correct. The rule say "This rule is triggered whenever raw HTML is used in a Markdown document:" or the check is false all 'html like' <foo> is detected as HTML even if foo is not an HTML word. I will check micromark parser at same time, thanks

mysiki avatar Jun 07 '25 20:06 mysiki

HTML will treat an unrecognized element name as a span. It could also be a custom element. This rule deliberately does not try to filter for element names defined by any specific HTML standard version.

https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Testing/HTML_and_CSS#html_fallback_behavior

DavidAnson avatar Jun 07 '25 22:06 DavidAnson