[BUG - Develop] `EvForm` generates extraneous ANSI codes
See original GitHub issueDescribe the bug
Putting styling in an EvForm template seems to result in the style being extraneously re-applied further down the form. The issue is masked by the way ANSI code is parsed by consoles - I only discovered it through the webclient.
To Reproduce
I don’t fully understand what’s happening well enough to create a reproducible test case, but here’s the situation where I identified the problem.
My form text:
.----------------------------------------------------------------------------.
| |wNAME|n: xxxxxxxxxx1xxxxxxxxxxxx xxxx2xxxxx F A T E xxxxxxxxxxxxxxxxxxxx |
| /x4x|n\\ xxxxxxxxxxxxxxxxxxxx |
| |wDESC|n: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx [-----] xxxxxxxxx0xxxxxxxxxx |
| xxxxxxxxxxxx3xxxxxxxxxxxxxxxxxxx \\x5x/ xxxxxxxxxxxxxxxxxxxx |
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx REFRESH xxxxxxxxxxxxxxxxxxxx |
>--------------------------------------------------------------------------<
| |*> ASPECTS > > > > > > > > > |n | |*> SKILLS > > > > > > > > > > > > > > > > > |n |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
| ccccccccccccAccccccccccccccc | ccccccccccccccccccccccBcccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
>--------------------------------------------------------------------------<
| |*(Phys) > > STRESS < < (Ment)|n | |*> STUNTS and EXTRAS > > > > > > > > > > > |n |
| xxxxxx6xxxxxx xxxxxx7xxxxxx | ccccccccccccccccccccccccccccccccccccccccccc |
| | ccccccccccccccccccccccccccccccccccccccccccc |
| |*> CONSEQUENCE > > > > > > > |n | ccccccccccccccccccccccccccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccDcccccccccccccccccccc |
| ccccccccccccCccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
| cccccccccccccccccccccccccccc | ccccccccccccccccccccccccccccccccccccccccccc |
----------------------------------------------------------------------------
The output to my log via logger.log_msg
:
.----------------------------------------------------------------------------.
| ^[1m^[37mNAME^[0m: ^[0mGM(#1) ^[0m^[1m^[37m^[0m ^[0mthey/them ^[0m^[1m^[37m^[0m^[0m^[0m^[1m^[37m^[0m F A T E ^[0m^[1m^[37m . ^[0m ^[0m^[1m^[37m^[0m^[0m^[0m^[1m^[37m^[0m^[0m^[0m^[1m^[37m^[0m^[0m^[0m^[1m^[37m^[0m |
| /^[0m.0.^[0m^[0m\ ^[0m^[1m^[37m^[0m^[1m^[37m.!=== / \ =========^[0m ^[0m^[0m^[0m^[0m |
| ^[1m^[37mDESC^[0m: ^[0mThis is User #1. ^[0m^[1m^[37m^[0m [-----] ^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[1m^[37m=!== /___\ ! !== ^[0m ^[0m^[1m^[37m^[0m |
| ^[0m ^[0m \^[0m.3.^[0m^[0m^[0m/ ^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[1m^[37m.! / \ ! !===^[0m ^[0m |
| ^[0m ^[0m REFRESH ^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[1m^[37m^[0m CORE MU* ^[0m |
>--------------------------------------------------------------------------<
| ^[7m> ASPECTS > > > > > > > > > ^[0m | ^[7m> SKILLS > > > > > > > > > > > > > > > > > ^[0m |
| ^[0m^[0mconcept ^[0m ^[0m^[0m^[0mI'm A Genius ^[0m ^[0m | ^[0m^[0mGreat (+4) ^[0m .......^[0m^[0m^[0mDecei, Lore, Resou ^[0m ....^[0m^[0m^[0m^[0m^[0m^[0m^[0m^[0m^[0m |
| ^[0m^[0mtrouble ^[0m ^[0m^[0m^[0mOh No! ^[0m ^[0m | ^[0m^[0mGood (+3) ^[0m ........^[0m^[0m^[0mCraft, Inves, Rappo ^[0m ...^[0m^[0m^[0m^[0m^[0m^[0m^[0m^[0m^[0m |
| ^[0m ^[0m^[0m ^[0m | ^[0m^[0mFair (+2) ^[0m ........^[0m^[0m^[0mConta, ^[0mFight, ^[0mPr[...]...^[0m^[0m^[0m^[0m^[0m |
| ^[0m ^[0m^[0m ^[0m | ^[0m^[0mAverage (+1) ^[0m .....^[0m^[0m^[0mBurgl, ^[0mEmpat, ^[0mPh[...]...^[0m^[0m^[0m^[0m^[0m |
| ^[0m ^[0m^[0m ^[0m | ^[0m^[0mMediocre (+0) ^[0m ....^[0m^[0m^[0mAthle, ^[0mDrive, ^[0mNotic, ^[0m...^[0m^[0m^[0m^[0m^[0m |
| ^[0m ^[0m^[0m ^[0m | ^[0m...................^[0m^[0m^[0mShoot^[0m...................^[0m^[0m^[0m^[0m^[0m |
>--------------------------------------------------------------------------<
| ^[7m(Phys) > > STRESS < < (Ment)^[0m | ^[7m> STUNTS and EXTRAS > > > > > > > > > > > ^[0m |
| ^[0m^[1m^[37m[1]^[0m^[1m^[37m[2]^[0m[3][4] ^[0m ^[0m.^[1m^[37m[1]^[0m^[1m^[37m[2]^[0m[3][4]^[0m^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[0m | ^[0m^[0mstunts ^[0m ^[0m^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[0m^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[0m^[0m^[1m^[37m^[0m^[1m^[37m^[0m^[0m |
| | ^[0m^[0mextras ^[0m ^[0m |
| ^[7m> CONSEQUENCE > > > > > > > ^[0m | ^[0m ^[0m^[7m^[0m |
| ^[0m^[0m^[1m^[37m[2]^[0m ^[0m ^[0m | ^[0m ^[0m |
| ^[0m^[0m^[1m^[37m[4]^[0m ^[0m ^[0m | ^[0m ^[0m |
| ^[0m^[0m^[1m^[37m[6]^[0m ^[0m ^[0m | ^[0m ^[0m |
| ^[0m^[0m[2] ^[0m ^[0m | ^[0m ^[0m |
----------------------------------------------------------------------------
To highlight a specific line:
Input string:
| |*> CONSEQUENCE > > > > > > > |n | ccccccccccccccccccccccccccccccccccccccccccc |
Output string:
| ^[7m> CONSEQUENCE > > > > > > > ^[0m | ^[0m ^[0m^[7m^[0m |
There are a ton of extra ANSI normal flags all throughout the text, but those aren’t in themselves much of an issue - it’s the reoccurrence of previous flags that’s concerning.
Develop-branch commit
6edf9064c
Additional context
After seeing what’s going on, I can (and will) patch text2html
to correct for it by having the ANSI normal flag override any previous adjacent flags, which should fix the user-facing issues. However, there’s clearly something amiss in the way the form template is being converted that should likely be addressed at some point.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
No worries. Just fyi, I have refactored EvForm quite a bit (hopefully push today, but I need to look at another EvForm-related issue you posted first 😉 )
So one thing that happens with this is that
EvCell
generatesANSI_NORMAL
markers on either side of each line of a rectangle. In contrast, EvForm will escape any|-
type markup, so what comes out of EvForm will be a mixture of|n
and^[0m^[1m^
(the actual parsing of the former happen when you send the data to the protocol). This is of course not ideal.But the future plan is to modify how we deal with markup (this goes beyond webclient, it’s a change for all prototocols) so I prefer to not mess more with it. In the future, the correct way would be to only see
|-
style markers coming out ofEvForm
, and they not being parsed to something until it hits the protocol.