Comments (7)
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.
Related to #464
from markdownlint.
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.
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.
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.
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.
Sounds reasonable. Feel free to close! Appreciate the discussion.
from markdownlint.
Related Issues (20)
- MD033 - Inline HTML Not ignoring custom HTML tags, but recognizing them as tags HOT 2
- MD033: Organizing information with collapsed sections HOT 7
- MD045: no-alt-text triggered even though html alt-text is specified HOT 2
- QUESTION: Is it possible to write custom linting rules, including Quick Fix information, for frontmatter? HOT 2
- Copyright HOT 1
- MD056/table-column-count counts pipes inside backticks as column separators HOT 2
- MD014 only considers the `$` sign, is this intentional? HOT 2
- Umlauts like Ä, Ö, Ü in Mailadresses/URLs are not detected as normal letters HOT 5
- HTML disable/enables comments triggered when inside Markdown inline code HOT 4
- Frontmatter interpreted as top-level heading HOT 7
- `markdownlint-disable-next-line` should apply to the next non-empty line HOT 1
- MD045 shown when image has alt text in the optional title HOT 3
- MD029/ol-prefix: Continuous list with more than 10 elements HOT 1
- Include additional schema/types for strict rule name verification HOT 2
- Diabling rules from the front matter? HOT 2
- 11 12 14 16 HOT 3
- Reference links are lost between dollar signs HOT 7
- Feature Request: Recognize `markdownlint-*` configuration comments in "non-HTML comments" (unused link reference definitions) HOT 1
- MD036: doesn't fire when any HTML comment is present on the same line.
- MD018 error for ID selectors in inline CSS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdownlint.