DEV Community

Discussion on: Using Dark/Light Mode Specific Images in GitHub Markdown

Collapse
 
lionelrowe profile image
lionel-rowe

Really not a fan of GitHub's approach here. Markdown is supposed to be a format that's compatible with many platforms, and a valid URL can only have one hash. That means that other platforms either have to implement the URL hash matching logic along with the gh-* names, or they have to implement it in an inconsistent way, such as through query params (https://example.com/img.jpg?gitlab-theme=dark&discourse-theme=dark&some-other-platform=dark#gh-dark-mode-only). Why not just use a single, cross-platform query param (?theme=dark), add this as a documented part of GitHub-flavored markdown, and be done with it? Other platforms that fully or partially support GFM can then add support in their own time, without using up the single "slot" in the URL's hash or using explicitly gh-* named parameters.

Collapse
 
lionelrowe profile image
lionel-rowe

I guess they are owned by Microsoft now so maybe we shouldn't be surprised by this kind of embrace-extend-extinguish bullshit.

Collapse
 
nicolus profile image
Nicolas Bailly

To be fair github started using "github flavored markdown" (which basically means that if you clone a repository on any other host your readme.md will not display correctly) loooong before Microsoft every thought about buying them.

Thread Thread
 
lionelrowe profile image
lionel-rowe

I'm on board with GFM, especially now it has become a de-facto standard (albeit one among several). Ideally there'd be a proper spec for it, but there isn't one of those even for the original version of Markdown.

The problem with gh-* hash params is that it forces other implementers of GFM to implement this explicitly GitHub-centric API that even end users have to know about. I mean maybe that's intentional from a "branding" point of view, but it's incredibly obnoxious from a design point of view.

Collapse
 
arnavkr profile image
Arnav Kumar

Microsoft keep doing unusual things 😑

Collapse
 
arnavkr profile image
Arnav Kumar

I am totally agree with your points here. And also i didn't like how they restricted to the images that are only hosted via github. Ig they did that to overcome that hash issue in urls. They might have thought that if they won't allow any other urls, there won't be any problems in using hash.
tbh its a very bad and untidy approach to simple thing. In my views either the query paramaters are good or specifying them as options like ![Dark](https://example.com/dark_img.png){theme = dark}.

Seems like its time to open an issue at the their support or in the github repo

Collapse
 
arnavkr profile image
Arnav Kumar

In the community the actual guy who requested for the feature actually had suggested somewhat better approach but the GitHub doesn't seem to take his suggestions.

Image

Some comments have been hidden by the post's author - find out more