[GH-ISSUE #249] Investigate generalized support for skipping block/inline content via regular expression (or similar) #213

Open
opened 2026-03-03 01:24:44 +03:00 by kerem · 8 comments
Owner

Originally created by @XhmikosR on GitHub (Jan 24, 2020).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/249

Hey, @DavidAnson!

I have a WIP branch in https://github.com/twbs/bootstrap/compare/master-xmr-markdownlint where I'm trying to add markdownlint through markdownlint-cli.

It seems I'm hitting a few issues and I'm not sure how to proceed. I mean, most are due to our mix of Hugo shortcodes, but I'm reaching out in case you have any suggestions or if any improvements can be made.

CI link so make things a little easier

site/content/docs/4.3/components/collapse.md:87 MD046/code-block-style Code block style [Expected: fenced; Actual: indented]

This seems a false positive since the block is inside a Hugo shortcode ({{< example >}}). If I change this to consistent it no longer complains. Or if I just remove the newline.

 site/content/docs/4.3/getting-started/introduction.md:121 MD034/no-bare-urls Bare URL used [Context: "https://twitter.com/{{<"]

This is also a false positive because the URLs also have a hugo function (- Follow [@getbootstrap on Twitter](https://twitter.com/{{< param twitter >}}).). I'm not sure if you can do anything about this

  1. Is there any way to ignore specific blocks without using inline comments? For example, say I want to skip all {{< markdown >}} blocks.
Originally created by @XhmikosR on GitHub (Jan 24, 2020). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/249 Hey, @DavidAnson! I have a WIP branch in https://github.com/twbs/bootstrap/compare/master-xmr-markdownlint where I'm trying to add markdownlint through markdownlint-cli. It seems I'm hitting a few issues and I'm not sure how to proceed. I mean, most are due to our mix of Hugo shortcodes, but I'm reaching out in case you have any suggestions or if any improvements can be made. [CI link](https://github.com/twbs/bootstrap/runs/407406418#step:9:235) so make things a little easier 1. ``` site/content/docs/4.3/components/collapse.md:87 MD046/code-block-style Code block style [Expected: fenced; Actual: indented] ``` This seems a false positive since the block is inside a Hugo shortcode (`{{< example >}}`). If I change this to `consistent` it no longer complains. Or if I just remove the newline. 2. ``` site/content/docs/4.3/getting-started/introduction.md:121 MD034/no-bare-urls Bare URL used [Context: "https://twitter.com/{{<"] ``` This is also a false positive because the URLs also have a hugo function (`- Follow [@getbootstrap on Twitter](https://twitter.com/{{< param twitter >}}).`). I'm not sure if you can do anything about this 3. Is there any way to ignore specific blocks without using inline comments? For example, say I want to skip all `{{< markdown >}}` blocks.
Author
Owner

@DavidAnson commented on GitHub (Jan 24, 2020):

I’ll try to respond to these as I have time. I’m on my phone at the moment, but I think I can help with the first question.

The markdown-it parser does not recognize Hugo syntax; the line it reports appears to be the first that is indented by four spaces which represents a code block. You can see this by pasting the content here: https://markdown-it.github.io/

What I think you want is for these Hugo blocks to be treated as code and in order to do that you might have the best luck with a custom markdown-it plugin. The last four test cases in this project show how to reference plug-ins. A quick search of npm did not turn up an existing one, but maybe you can find one or thinking about adding one.

<!-- gh-comment-id:578210858 --> @DavidAnson commented on GitHub (Jan 24, 2020): I’ll try to respond to these as I have time. I’m on my phone at the moment, but I think I can help with the first question. The markdown-it parser does not recognize Hugo syntax; the line it reports appears to be the first that is indented by four spaces which represents a code block. You can see this by pasting the content here: https://markdown-it.github.io/ What I think you want is for these Hugo blocks to be treated as code and in order to do that you might have the best luck with a custom markdown-it plugin. The last four test cases in this project show how to reference plug-ins. A quick search of npm did not turn up an existing one, but maybe you can find one or thinking about adding one.
Author
Owner

@DavidAnson commented on GitHub (Jan 24, 2020):

For the second issue, the content as it exists does contain a bare link according to CommonMark rules: https://markdown-it.github.io/#md3=%7B%22source%22%3A%22Follow%20%5B%40getbootstrap%20on%20Twitter%5D%28https%3A%2F%2Ftwitter.com%2F%7B%7B%3C%20param%20twitter%20%3E%7D%7D%29.%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D

In this case, I’m not sure a custom plug-in would help because the scenario is not recognizing the new syntax, but modifying an existing one.

Would it be possible for you to lint these files after the Hugo tags had been applied?

<!-- gh-comment-id:578213431 --> @DavidAnson commented on GitHub (Jan 24, 2020): For the second issue, the content as it exists does contain a bare link according to CommonMark rules: https://markdown-it.github.io/#md3=%7B%22source%22%3A%22Follow%20%5B%40getbootstrap%20on%20Twitter%5D%28https%3A%2F%2Ftwitter.com%2F%7B%7B%3C%20param%20twitter%20%3E%7D%7D%29.%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D In this case, I’m not sure a custom plug-in would help because the scenario is not recognizing the new syntax, but modifying an existing one. Would it be possible for you to lint these files after the Hugo tags had been applied?
Author
Owner

@DavidAnson commented on GitHub (Jan 24, 2020):

I think the answer to the third question is a custom plug-in for Hugo.

For questions number one and number three, I think a custom plug-in that understands Hugo syntax will do what you want. For question number two, I’m not sure.

<!-- gh-comment-id:578214492 --> @DavidAnson commented on GitHub (Jan 24, 2020): I think the answer to the third question is a custom plug-in for Hugo. For questions number one and number three, I think a custom plug-in that understands Hugo syntax will do what you want. For question number two, I’m not sure.
Author
Owner

@XhmikosR commented on GitHub (Feb 7, 2020):

So I guess it boils down to I'd there's a way to skip some snippets. Does
this sound like a good addition?

On Fri, Jan 24, 2020, 19:00 David Anson notifications@github.com wrote:

I think the answer to the third question is a custom plug-in for Hugo.

For questions number one and number three, I think a custom plug-in that
understands Hugo syntax will do what you want. For question number two, I’m
not sure.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/DavidAnson/markdownlint/issues/249?email_source=notifications&email_token=AACVLNOZBH2FDF6W5OPE2SDQ7MNDVA5CNFSM4KLIOUXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ3NUXA#issuecomment-578214492,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AACVLNJYYVVRF5FKMVFEY4DQ7MNDVANCNFSM4KLIOUXA
.

<!-- gh-comment-id:583661454 --> @XhmikosR commented on GitHub (Feb 7, 2020): So I guess it boils down to I'd there's a way to skip some snippets. Does this sound like a good addition? On Fri, Jan 24, 2020, 19:00 David Anson <notifications@github.com> wrote: > I think the answer to the third question is a custom plug-in for Hugo. > > For questions number one and number three, I think a custom plug-in that > understands Hugo syntax will do what you want. For question number two, I’m > not sure. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/DavidAnson/markdownlint/issues/249?email_source=notifications&email_token=AACVLNOZBH2FDF6W5OPE2SDQ7MNDVA5CNFSM4KLIOUXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ3NUXA#issuecomment-578214492>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AACVLNJYYVVRF5FKMVFEY4DQ7MNDVANCNFSM4KLIOUXA> > . >
Author
Owner

@DavidAnson commented on GitHub (Feb 8, 2020):

Are you suggesting generalized support for skipping certain kinds of block or inline content via regular expression or something? That could have some uses and would probably be sufficient for your purposes here. I’d worry about coming up with something that’s powerful enough without being too complicated, but I’d be happy to look into this for the next release.

<!-- gh-comment-id:583676047 --> @DavidAnson commented on GitHub (Feb 8, 2020): Are you suggesting generalized support for skipping certain kinds of block or inline content via regular expression or something? That could have some uses and would probably be sufficient for your purposes here. I’d worry about coming up with something that’s powerful enough without being too complicated, but I’d be happy to look into this for the next release.
Author
Owner

@XhmikosR commented on GitHub (Feb 11, 2020):

Yup, I guess this would solve any issues for our use case and similar ones. Not sure how hard it'll be to implement :)

<!-- gh-comment-id:584657660 --> @XhmikosR commented on GitHub (Feb 11, 2020): Yup, I guess this would solve any issues for our use case and similar ones. Not sure how hard it'll be to implement :)
Author
Owner

@DavidAnson commented on GitHub (Aug 5, 2023):

@XhmikosR, is this still relevant?

<!-- gh-comment-id:1666617070 --> @DavidAnson commented on GitHub (Aug 5, 2023): @XhmikosR, is this still relevant?
Author
Owner

@XhmikosR commented on GitHub (Dec 17, 2023):

@DavidAnson sorry for the late reply. Yes, this would help us a lot since we still need to exclude Hugo-specific blocks. It's been a while since I last ran Markdownlint against our repo, though.

<!-- gh-comment-id:1859198865 --> @XhmikosR commented on GitHub (Dec 17, 2023): @DavidAnson sorry for the late reply. Yes, this would help us a lot since we still need to exclude Hugo-specific blocks. It's been a while since I last ran Markdownlint against our repo, though.
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#213
No description provided.