Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Codidact Meta!

Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.

Comments on The mystery of the alt text warning in a post with no images

Post

The mystery of the alt text warning in a post with no images

+2
−0

Amusingly, a post about alt text triggered the missing alt text warning:

A post containing a code block that triggered the alt text warning

I can see why the warning was triggered - the post contains the markdown for an image, which has the standard placeholder text instead of a meaningful description. I'm very much in favour of the alt text warning in general, but in this case the markdown was inside a code block so the warning is not needed (there is no image in that post).

I'm raising this for completeness as it's technically a bug, but I don't see it as urgent to fix - I wouldn't be surprised if this is the only time it ever happens...

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Alas, there's a regex... (2 comments)
Alas, there's a regex...
Monica Cellio‭ wrote over 1 year ago

The regex governing this is const altRegex = /!\[(?:Image_alt_text)?\](?:\(.+(?!\\\))\)|\[.+(?!\\\])\])/gi; (in app/assets/javascripts/markdown.js, but if I try to touch a regex I might cause the world to end or something. Happy to get a PR from someone with more clues than I have!

trichoplax‭ wrote over 1 year ago · edited over 1 year ago

The regex would have to check whether the text is inside or outside a code block, which includes single back ticks, triple back ticks, code tags, plus all the back tick variations that markdown allows for special use cases. This would mean effectively writing a markdown renderer in regex, which would be horrible to maintain and almost certainly incorrect (regex would not be a suitable tool for this).

It sounds like fixing this issue would require somehow hooking into the existing markdown renderer, or processing the already rendered html, either of which would be a non trivial task.

Since I would expect this issue to come up very rarely (I only saw it because I was raising another issue about the alt text) it may not be worth fixing. I tried to hint in the post that this should probably be very low priority.