Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source command does not have an escape sequence for the markdown #79

Closed
bhagyajbijukumar opened this issue Nov 24, 2020 · 4 comments
Closed

Comments

@bhagyajbijukumar
Copy link
Contributor

image
see the above image

@ioistired
Copy link
Contributor

ioistired commented Nov 25, 2020

I started implementing this by just making the jsk_source command replace all occurrences of ``` with ``\N{zero width space}`, but then I noticed that since FilePaginator also uses WrappedPaginator with a fenced code block, it might be better to place this escaping code inside a new commands.Paginator subclass that's used as the base for all other base Paginator classes. Something like this:

def __init__(self, ...):
    self.escape_code_blocks = False
    if '```' in prefix and '```' in suffix:
        self.escape_code_blocks = True

def add_line(self, line):
    if self.escape_code_blocks:
        line = line.replace('```', '``\N{zero width space}`')
        super().add_line(line)

Let me know what you think @Gorialis

@bhagyajbijukumar
Copy link
Contributor Author

i have earlier used discord.utils.escape_markdown from the discordpy library in my project isn't it possible to use that function?

@Gorialis Gorialis added the bug label Jan 17, 2021
@Gorialis
Copy link
Owner

I merged #92 a while ago, but I realized in auditing later that it actually produces a lot of formatting inconsistencies (all underscores get "escaped"). I'll probably end up favoring this implementation, but we'll see how it goes when I have time to do some proper QA.

@Gorialis
Copy link
Owner

Discord recently added an interactive, syntax highlighted, file preview feature on the desktop and web clients.

As this is the most common usage vector for Jishaku, and the intuitiveness greatly exceeds home-rolled solutions, as of 9099fe0, Jishaku will now check the file upload limit and, if the source file content fits within it, will upload the content as a file instead.

image

This circumvents the need for escaping in this case, but in the case it does not fit, the handling has been changed to favor @iomintz 's implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants