chipzoller / hugo-clarity

A theme for Hugo based on VMware Clarity
Other
582 stars 267 forks source link

Allow empty imagecaps #283

Closed rootwork closed 2 years ago

rootwork commented 2 years ago

This PR...

This builds on #278, so that PR should be resolved before reviewing this one.

Changes / fixes

Currently there is no way for an image to have alt text but no caption; that is, empty Markdown title text in the image:

![Foo](foo.png " ")

This PR fixes that. As in the example, alt text with an empty caption requires a space in the title. I was hoping to be able to just pass an empty string ("") but as an empty string in JS is falsy -- the same as when it doesn't exist at all -- there didn't seem to be any way to do that and still have the alt text fall-back.

Screenshots (if applicable)

allow-empty-titles

This PR updates the "Markdown Syntax Guide" posts with an example of providing alt text and an empty caption. Note this will result in the image having an empty title attribute (well, technically, an attribute consisting of one space) but I don't see any way around that. Since the alt text would be used for a11y, I don't think there's anything wrong with that.

Checklist

Ensure you have checked off the following before submitting your PR.

rootwork commented 2 years ago

@onweru Just to be clear, did you also review #278 or just the changes that are only in this PR? As I said at the top, this builds on 278; the changes in this PR alone are actually pretty small.

But if you reviewed everything in the context of this PR, then I'll go ahead and merge this and 278.

rootwork commented 2 years ago

The two commits unique to this PR are 2e7afb8 (#283) and 20515b8 (#283)