DavidAnson / markdownlint

A Node.js style checker and lint tool for Markdown/CommonMark files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignore long lines in HTML comments

ruzickap opened this issue · comments

Hello.

Is there a way how to skip all checks inside the HTML comments in markdown file?

Example:

$ cat > test.md << \EOF
<!---
ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+
-->

[//]: # ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+
EOF

$ markdownlint test.md
test.md:2:81 MD013/line-length Line length [Expected: 80; Actual: 121]
test.md:5:81 MD013/line-length Line length [Expected: 80; Actual: 129]

❯ markdownlint --version
0.38.0

It would be nice if markdownlint will ignore everything inside <!--- ... -->.

Currently I do not know how to ignore commented long like in markdown.

Thank you

The content of HTML comments is generally ignored by default. In the case here, MD013 is operating in its default/enabled configuration which reports lines longer than 80 characters as being too long. Unlike some Markdown constructs, HTML comments can be wrapped so this is possible/easy to address. You can read more here: https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md.

The second line you show is not an HTML comment, but a valid link reference definition. It is not reported as being unused because that pattern is specifically ignored. More info on that here: https://github.com/DavidAnson/markdownlint/blob/main/doc/md053.md. But it can be easily wrapped as well.

If you don't like this rule, you can disable it using any of the techniques described in the documentation. But here is your example updated to produce no violations of the line-length rule:

https://dlaa.me/markdownlint/#%25m%23%20Issue%201080%0A%0A%3C!--%0AComponentStatus%20(and%20ComponentStatusList)%20holds%20the%20cluster%20validation%20info.%0ADeprecated%3A%20This%20API%20is%20deprecated%20in%20v1.19%2B%0A--%3E%0A%0A%5B%2F%2F%5D%3A%20%23%20ComponentStatus%20(and%20ComponentStatusList)%20holds%20the%20cluster%20validation%20info.%0ADeprecated%3A%20This%20API%20is%20deprecated%20in%20v1.19%2B%0A%0A%3C!--%20markdownlint-enable-file%20md013%20--%3E

Update: The example link reference definition is almost valid. If it is quoted properly, it will not report a length violation even without wrapping:

[//]: # "ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+"

Thank you for a quick reaction David.
You are right in both cases, but the sentence I use is just example.

My real usecase is:

I have some command (visible to the reader) in markdown and then the command's output which should be hidden for the user (but needs to be preserved for the "technical writer"):

# Issue 1080

This is my command:

```bash
kubectl stern -n cert-manager . --tail 5 --since 1h --no-follow
```

<!--
+ cert-manager-webhook-54f9d96756-8nbqx › cert-manager-webhook
+ cert-manager-777fbdc9f8-qhk2d › cert-manager-controller
+ cert-manager-cainjector-65857fccf8-t68lk › cert-manager-cainjector
cert-manager-cainjector-65857fccf8-t68lk cert-manager-cainjector I0624 11:34:24.790420       1 reconciler.go:118] "cert-manager: could not find any ca data in data source for target" kind="validatingwebhookconfiguration" kind="validatingwebhookconfiguration" name="cert-manager-webhook"
cert-manager-cainjector-65857fccf8-t68lk cert-manager-cainjector I0624 11:34:25.603904       1 reconciler.go:142] "cert-manager: Updated object" kind="mutatingwebhookconfiguration" kind="mutatingwebhookconfiguration" name="cert-manager-webhook"
cert-manager-cainjector-65857fccf8-t68lk cert-manager-cainjector I0624 11:34:25.604466       1 reconciler.go:142] "cert-manager: Updated object" kind="validatingwebhookconfiguration" kind="validatingwebhookconfiguration" name="cert-manager-webhook"
cert-manager-cainjector-65857fccf8-t68lk cert-manager-cainjector I0624 11:34:25.609019       1 reconciler.go:142] "cert-manager: Updated object" kind="mutatingwebhookconfiguration" kind="mutatingwebhookconfiguration" name="cert-manager-webhook"
cert-manager-cainjector-65857fccf8-t68lk cert-manager-cainjector I0624 11:34:25.609755       1 reconciler.go:142] "cert-manager: Updated object" kind="validatingwebhookconfiguration" kind="validatingwebhookconfiguration" name="cert-manager-webhook"
cert-manager-777fbdc9f8-qhk2d cert-manager-controller I0624 11:39:26.254284       1 acme.go:233] "cert-manager/certificaterequests-issuer-acme/sign: certificate issued" resource_name="ingress-cert-staging-tnp9z" resource_namespace="cert-manager" resource_kind="CertificateRequest" resource_version="v1" related_resource_name="ingress-cert-staging-tnp9z-569747980" ...
- cert-manager-cainjector-65857fccf8-t68lk › cert-manager-cainjector
cert-manager-777fbdc9f8-qhk2d cert-manager-controller I0624 11:39:26.254523       1 conditions.go:252] Found status change for CertificateRequest "ingress-cert-staging-tnp9z" condition "Ready": "False" -> "True"; setting lastTransitionTime to 2023-06-24 11:39:26.254515881 +0000 UTC m=+301.629669662
cert-manager-777fbdc9f8-qhk2d cert-manager-controller I0624 11:39:26.309171       1 controller.go:162] "cert-manager/certificates-readiness: re-queuing item due to optimistic locking on resource" key="cert-manager/ingress-cert-staging" error="Operation cannot be fulfilled on certificates.cert-manager.io \"ingress-cert-staging\": the object has been modified; please ...
cert-manager-777fbdc9f8-qhk2d cert-manager-controller I0624 11:39:26.322662       1 controller.go:162] "cert-manager/certificates-issuing: re-queuing item due to optimistic locking on resource" key="cert-manager/ingress-cert-staging" error="Operation cannot be fulfilled on certificates.cert-manager.io \"ingress-cert-staging\": the object has been modified; please ...
cert-manager-777fbdc9f8-qhk2d cert-manager-controller I0624 11:39:26.331743       1 controller.go:162] "cert-manager/certificates-key-manager: re-queuing item due to optimistic locking on resource" key="cert-manager/ingress-cert-staging" error="Operation cannot be fulfilled on certificates.cert-manager.io \"ingress-cert-staging\": the object has been modified; ...
- cert-manager-777fbdc9f8-qhk2d › cert-manager-controller
cert-manager-webhook-54f9d96756-8nbqx cert-manager-webhook I0624 11:34:50.197304       1 logs.go:59] http: TLS handshake error from 192.168.113.49:47560: EOF
cert-manager-webhook-54f9d96756-8nbqx cert-manager-webhook I0624 11:34:50.200121       1 logs.go:59] http: TLS handshake error from 192.168.113.49:47572: read tcp 192.168.10.192:10250->192.168.113.49:47572: read: connection reset by peer
cert-manager-webhook-54f9d96756-8nbqx cert-manager-webhook I0624 11:38:31.687229       1 logs.go:59] http: TLS handshake error from 192.168.113.49:54464: EOF
cert-manager-webhook-54f9d96756-8nbqx cert-manager-webhook I0624 11:39:26.294153       1 logs.go:59] http: TLS handshake error from 192.168.113.49:49836: EOF
cert-manager-webhook-54f9d96756-8nbqx cert-manager-webhook I0624 11:39:26.318155       1 logs.go:59] http: TLS handshake error from 192.168.113.49:49852: EOF
- cert-manager-webhook-54f9d96756-8nbqx › cert-manager-webhook
-->

Anyway - I solved it using <!-- markdownlint-disable --> like mentioned in Configuration section:

# Issue 1080

This is my command:

```bash
kubectl stern -n cert-manager . --tail 5 --since 1h --no-follow
```

<!-- markdownlint-disable -->
<!--
Many very long lines...
-->
<!-- markdownlint-restore -->

Thank you for a quick response...