misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform πŸš€
https://misskey-hub.net/
GNU Affero General Public License v3.0
10.11k stars 1.38k forks source link

MFM: rendering of `fg` and `bg` #10904

Open Johann150 opened 1 year ago

Johann150 commented 1 year ago

Summary

In the rendering of $[fg ] and $[bg ], the default colors are #f00 for both. This means that if both functions are used on a piece of text, the text will have the same color as the background and will be unreadable. Maybe it would be better to have different default values for the two. For example, change the bg default color to #0f0.

Further, I think the color regex incorrectly matches 4 and 5 digit color codes: https://github.com/misskey-dev/misskey/blob/fb54c58a661bee64365b7ec0c52d456062aaa200/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts#L208 Technically, 4 digit color codes do exist if you want to include the alpha channel, but then you should also accept 8 digit color codes. 5 digit color codes do not exist.

I suggest this alternative regex, which only matches 3 or 6 digit color codes: /^([0-9a-f]{3}){1,2}$/i

futchitwo commented 1 year ago
Johann150 commented 1 year ago

Oh I didn't see that issue. I guess that can be handled there separately then. The only thing that remains here is changing the default color of bg then.

EbiseLutica commented 1 year ago

#xxx #xxxx #xxxxxx #xxxxxxxx γ«ε―ΎεΏœγ•γ›γ‚‹γͺら、 /^([0-9a-f]{3,4}){1,2}$/i かγͺ

Johann150 commented 1 year ago

That will also match 7 digit ones which do not exist because the 3,4 part can be different on repetitions. I think the shortest you can get is this: /^(([0-9a-f]{3}){1,2}|([0-9a-f]{4}){1,2})$/i

acid-chicken commented 1 year ago

/^([\da-f]{3}|([\da-f]{2}){2,4})$/i