[GH-ISSUE #1631] MD033 : Hugo shortcode support #2573

Closed
opened 2026-03-07 20:09:00 +03:00 by kerem · 3 comments
Owner

Originally created by @mysiki on GitHub (Jun 7, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1631

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

Originally created by @mysiki on GitHub (Jun 7, 2025). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1631 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
kerem 2026-03-07 20:09:00 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Jun 7, 2025):

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

<!-- gh-comment-id:2952727695 --> @DavidAnson commented on GitHub (Jun 7, 2025): > 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
Author
Owner

@mysiki commented on GitHub (Jun 7, 2025):

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

<!-- gh-comment-id:2952952250 --> @mysiki commented on GitHub (Jun 7, 2025): 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
Author
Owner

@DavidAnson commented on GitHub (Jun 7, 2025):

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

<!-- gh-comment-id:2953154443 --> @DavidAnson commented on GitHub (Jun 7, 2025): 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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2573
No description provided.