diff options
author | 2019-09-18 08:55:56 +0200 | |
---|---|---|
committer | 2019-09-18 08:55:56 +0200 | |
commit | 6815bca50816678f6069516ef564ecb4a4d01d83 (patch) | |
tree | 233eb11beda1ee55c32b89da3323f6eb66c0a9e5 /tests/conftest.py | |
parent | Add basic tests for `bot.api`. (#424) (diff) |
Escape markdown in codeblock suggestion embed
https://github.com/python-discord/bot/issues/434
If the content we prepare for the codeblock suggestion embed defined
in the `bot` cog contains markdown characters (e.g., `__`, `**`), this
will cause Discord to apply markdown, since both the codeblock syntax
example as well as the codeblock result example will contain the
characters, making it a matched formatting pair.
This will hide those characters, which often have a function in the
code, and break the example of a formatted codeblock.
To deal with that, I've added a regex substitution that substitutes
markdown characters by an escaped version of that markdown character.
Example:
`'__hello__'` will become `'\_\_hello\_\_'`
I've added this substitution to both paths in the `on_message` event
listener, since we can't substitute at an earlier place due to it
generating `SyntaxErrors` with the `ast.parse` check.
This closes #434
Diffstat (limited to 'tests/conftest.py')
0 files changed, 0 insertions, 0 deletions