Fix: Update markdown image for dark/light mode#36922
Fix: Update markdown image for dark/light mode#36922mykh-hailo wants to merge 2 commits intogo-gitea:mainfrom
Conversation
|
The |
|
@bircni I updated my code for you comments. |
|
@wxiaoguang can you check my for this issue please? |
|
|
One of the feasible approaches is "calling |
|
By the way, this PR is unnecessarily complex. You can simply allow the I don't understand why you need to do these: extract the "picture" node / parse the attributes / transform to other layouts. |
|
@wxiaoguang My approach works like this: The |
|
I think we shouldn't touch The only thing need to do is to support |
93bd290 to
5217897
Compare
5217897 to
1b5c9f6
Compare
|
@wxiaoguang thank you for the quick update. |
|
I think it can be like this e1156fe |
|
@wxiaoguang I'd appreciate it if you can give me the ETA for the merge please. |
|
Wait for 2 maintainer's approvals. By the way, please update the PR's description |
Description
This PR improves how Gitea renders Markdown images for dark/light mode to match GitHub behavior more closely.
Closes: #35545
Markdown image dark/light switching
Enhanced the Markdown HTML sanitizer to allow GitHub’s / elements and required attributes (media, srcset).
Updated the Markdown post-processing so that:
The fallback
inside remains a direct child (so browsers correctly apply
<source media="(prefers-color-scheme: ...)" ...>selection).<source srcset="...">URLs are rewritten/resolved consistently with how<img src="...">URLs are handled.CSS behavior
Added the
prefers-color-scheme rulesfor#gh-dark-mode-only/#gh-light-mode-onlyso the correct image is shown automatically in dark vs light mode.