GithubHelp home page GithubHelp logo

Comments (7)

DavidAnson avatar DavidAnson commented on August 20, 2024

Thanks for the example! As you note, the issue is with a Hugo-specific syntax which is not part of CommonMark or GFM and therefore not recognized. You may wish to disable this rule for that line or file or project.

(If this pattern is common, you could also add ".pdf" to the allow-list.)

https://github.com/DavidAnson/markdownlint#configuration

from markdownlint.

hussainweb avatar hussainweb commented on August 20, 2024

Thank you for the quick response. My thought process here is that since the link syntax is still the same, this is something that is not necessarily incompatible with Markdown standards. (I am not an expert though and happy to be corrected.) At the same time, I recognize that this is unusual. If it is compatible with the link syntax ([text](<link>)), I am hoping that a parsing change here will allow it to work with the usual link syntax, regardless of what appears inside <link>.

Again, I am neither an expert nor a maintainer. The above is just a theory of how it could work. If you think this is workable, I'll appreciate it very much. FWIW, I am not facing issues with version 0.32.2 of the markdownlint-cli (corresponds to 0.26.2 of markdownlint).

from markdownlint.

DavidAnson avatar DavidAnson commented on August 20, 2024

This library is moving to use micromark for Markdown parsing: https://github.com/micromark/micromark

Searching very briefly, I do not see that anyone has added support for Hugo syntax: https://www.npmjs.com/search?q=Micromark%20Hugo%20

from markdownlint.

hussainweb avatar hussainweb commented on August 20, 2024

Thanks for the tip. I also think I was not entirely clear in my initial message. I am not asking to support Hugo syntax here. I only used that to show the problem. In my view, the parser should just interpret everything between the two braces ( and ) as a link and then not match proper names there. This already works for regular links but it breaks if special characters such as { and < come in.

Moreover, if you are moving to micromark for parsing, maybe they already handle this and you don't have to do anything. I will wait for the move and stick with the old version of the CLI for now.

Question: is there a planned release for micromark parsing or is it uncertain right now?

from markdownlint.

DavidAnson avatar DavidAnson commented on August 20, 2024

This rule has already been converted to use the micromark parser. The issue is that the Hugo syntax here is not a valid link according to the CommonMark specification: https://spec.commonmark.org/0.30/#links. Because it is not a valid link, it is treated as normal text and does not get the special treatment links do. If Hugo support were incorporated into micromark as an extension, this syntax would presumably be recognized as a link and the behavior you want would automatically result.

from markdownlint.

hussainweb avatar hussainweb commented on August 20, 2024

Thanks. That was very helpful. I found this (emphasis added):

A link destination consists of either
...
a nonempty sequence of characters that does not start with <, does not include ASCII control characters or space character, and includes parentheses only if (a) they are backslash-escaped or (b) they are part of a balanced pair of unescaped parentheses.

This means that the only reason this does not get parsed as a link is because of the space. There are no ASCII control characters and the parentheses are balanced.

Moreover, it turns out that Hugo doesn't care about spaces at all. So, if I remove all the spaces, it works for both markdownlint and Hugo. Example.

Still, I think this is hacky. Removing spaces in the beginning and end is one thing but it is very weird to remove the space between relref and the path. Like this: [Link 3]({{<relref'docs/organization.pdf'>}}).

So, I think my best option is to ignore the line with markdownlint-disable-next-line.

I'm okay to close this unless you have other ideas. I hope this finding is useful to someone or to me in the future 😀.

from markdownlint.

DavidAnson avatar DavidAnson commented on August 20, 2024

It's great that you figured that out! I assumed spaces were required and didn't think to suggest removing them. Good for you experimenting. :) I will go ahead and close this issue.

from markdownlint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.