Add special color case handling for older titles - #1
Conversation
codecat
left a comment
There was a problem hiding this comment.
Thanks for the PR! Damn, I really typo'd DefaultOptions everywhere huh..
I haven't looked at the actual implementation yet (I suspect there might be a better way?) but here's some preliminary notes.
| Parser.toHTML('$fRed'), | ||
| '<span style="color: #ff0000;">Red</span>'); | ||
|
|
||
| // this type of interpretation is unique to games older than maniaplanet, where "$fhe" is the color, and non-hex characters are treated as zeros |
There was a problem hiding this comment.
We should aim to have descriptions like these as part of the DefaultOptions file instead.
| nextToken.text += c; | ||
| } | ||
|
|
||
| shortColor = false |
|
I also think the name of the setting is misleading and doesn't really explain its intention. I have a better idea for the long run, but we should probably rename this to something like |
|
Is |
|
That name works. Yeah, you can add the documentation for that option in |
|
Should be good to go now. |
This PR adds a new option for
Parser.toHTML/parsecalledallowShortColors: boolean, that controls short-color behaviour to allow compatibility between older titles and this library, alongside a new testcase for said option calledshould handle incomplete color codes by cutting text off.Below is an example of it: