GithubHelp home page GithubHelp logo

Comments (7)

DavidAnson avatar DavidAnson commented on July 19, 2024

This seems like a fair amount of complexity for something (HTML in markdown) that is discouraged. Your examples are all for image tags; if that's the only real scenario, it might be easier to accomplish some other way?

from markdownlint.

nschonni avatar nschonni commented on July 19, 2024

Related to #464

from markdownlint.

mvilrokx avatar mvilrokx commented on July 19, 2024

This seems like a fair amount of complexity for something (HTML in markdown) that is discouraged.

Agreed. I think the specific Use Case is that some things just cannot be achieved with Markdown and require HTML (unless I am wrong). E.g., centering an image or controlling the size of the image so it fits properly in the document when it renders. "New Lines" inside table cells are another example, AFAIK, that can only be achieved with HTML tables and using the <br/> tag.

Maybe those are the only exceptions?

Also I just realized that the second example is different than the first because that is not an attribute on a tag. It would be a <br/> tag somewhere inside a <table> tag (i.e. only allow HTML tables if they are using a
tag.

If there is a finite list of these exceptions maybe they can be "hard-coded" somehow. Maybe add a flag to the no-inline-html called strict or something that is true by default, and behaves as it does now, but if you set it to false it allows certain tags with certain attributes, e.g. the image example I gave. Maybe start with just that and we can add "exceptions" over time?

Your examples are all for image tags; if that's the only real scenario, it might be easier to accomplish some other way?

I'm all ears :-)

from markdownlint.

DavidAnson avatar DavidAnson commented on July 19, 2024

Trying to extend MD033 in an abstract way to support these special cases seems difficult – as you outline above by calling out challenges with excluding versus including. On the other hand, if there are just a few special cases, maybe those can be handled specifically. For example, there could be a new rule called "simplify images" (or something) that looks for IMG tags with only SRC and ALT and recommends converting them to Markdown syntax (this would even be auto-fixable). A rule like "breaks inside tables" is something else that could be specifically allowed, probably by MD033 with a parameter to opt in. I'm not sure how many others of these there might be.

from markdownlint.

mvilrokx avatar mvilrokx commented on July 19, 2024

and recommends converting them to Markdown syntax (this would even be auto-fixable)

That is literally what I did; some regex-foo in VS Code to find them and then convert them to markdown images. That is also how I found out that I cannot convert them all.

Maybe we don't even need a new rule (for image conversion), it's basically a straight-up fix, like all other fixes, no? I mean, there is zero difference between <img src="./picture.png" alt="a picture" /> and ![a picture](./picture.png) so why not just fix these?

Here's another one: I caught people using <hr/>, those can be converted to ---

The trick will be that if these tags are used inside other HTML, it needs to stay HTML, otherwise you will break the rendering.

from markdownlint.

DavidAnson avatar DavidAnson commented on July 19, 2024

Every fix is done as part of a rule that can be disabled for scenarios where it does not make sense. That said, I'm not sure I want to create a bunch of rules around HTML since my stance is that HTML should be avoided as much as possible.

from markdownlint.

mvilrokx avatar mvilrokx commented on July 19, 2024

Sounds reasonable. Feel free to close! Appreciate the discussion.

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.