Pinacolada64 / NOW

A MUD under construction based on Evennia.
9 stars 8 forks source link

Stop escaping closing curly brace #21

Open Pinacolada64 opened 6 years ago

Pinacolada64 commented 6 years ago

https://github.com/Pinacolada64/NOW/blob/d71a1c6e74f50ef31dd14e8ccca2f8c3e14b5551/world/helpers.py#L46

This fixes formatting issues in spoof when text contains curly brace-enclosed phrases.

Pinacolada64 commented 6 years ago

Then again, maybe not.

AmberFennek commented 6 years ago

Here's CmdSpoof - it uses escape_braces in four different ways among various modes of spoof.

They are:

here.msg_contents(text=(' ' * indent + escape_braces(args.rstrip()), {'type': 'spoof'}))
here.msg_contents(text=(escape_braces(text.rstrip()), {'type': 'spoof'}))
here.msg_contents(text=(escape_braces(spoof.rstrip()), {'type': 'spoof'}), options={'raw': True})
here.msg_contents(text=(escape_braces(spoof.rstrip()), {'type': 'spoof'}))

The initial thought is that when not supplying format mappings to the msg_contents calls, the escape_braces wrapping is unnecessary and causing the back curly brace to duplicate. One way to test this is to remove all the escape_braces calls from the 5 different lines in CmdSpoof. instead of removing or modifying the escape_braces method, itself.

AmberFennek commented 6 years ago

Modify the lines like this:

here.msg_contents(text=(' ' * indent + args.rstrip(), {'type': 'spoof'}))
here.msg_contents(text=(text.rstrip(), {'type': 'spoof'}))
here.msg_contents(text=(spoof.rstrip(), {'type': 'spoof'}), options={'raw': True})
here.msg_contents(text=(spoof.rstrip(), {'type': 'spoof'}))

Before committing the code, we can test an altered commands/say.py that contained the CmdSpoof lines above and try to see if the unnecessary duplication persists, or if there's any side effect to no longer escaping braces in spoofs.

When you have the time, I can walk you through the workflow to pull the file, change it, and submit a pull request from the command line. Once a fix candidate is committed, we'll test. It should be rather simple, and a good opportunity to practice the workflow for submitting/testing code changes.

AmberFennek commented 6 years ago

It turns out that this is an issue with msg_contents in Evennia. @py self.location.msg_contents('A single open curly brace: {') @py self.location.msg_contents('A single close curly brace: }') @py self.location.msg_contents('A double open curly brace: {{') @py self.location.msg_contents('A double close curly brace: }}')

Note that the double open curly brace is escaped, even when no mapping kwarg is set. That's the issue.