flytegg / mc-utils

Community powered Minecraft utilities for developers, builders and players.
https://mcutils.com
29 stars 16 forks source link

Apply MC color formatting algorithmically #202

Closed Tofpu closed 6 months ago

Tofpu commented 7 months ago

Written from scratch to apply the colors algorithmically. From what I understand, we are not able to reliable remove inherited decorations purely via CSS, as seen in issue https://github.com/flytegg/mc-utils/issues/200. So I went with a systematic approach to eliminate the decorations' inheritance problem once and for all by iterating through each char of given input and handling it appropriately.

Regarding tests, I tested the test cases mentioned in PR with this changes and compared it in-game and I can confirm that everything matches. I also introduced couple more tests below to verify that multi lines and gradient works as expected.

Since this completely changes how we apply the colors, we need to make sure this works as expected😄

A quick comparison:

Test cases (built on top of previous PR):

Tofpu commented 7 months ago

From what I can tell, this PR is ready now. Feel free to test the changes out when y'all could. I'm open to any feedback as usual! :)

joshbker commented 6 months ago

Hi @Tofpu, I'm going to merge this PR into a branch inside of the mc-utils repo so that it deploys a preview branch. I'll make a new PR afterwards to be reviewed. Thanks :)