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

Don't apply trimming within code blocks #21

Open
zlmarshall opened this issue Jul 18, 2024 · 0 comments
Open

Don't apply trimming within code blocks #21

zlmarshall opened this issue Jul 18, 2024 · 0 comments

Comments

@zlmarshall
Copy link
Contributor

We're using a pretty standard setup of Discourse with email integration, and it looks like even within code blocks the trimming rules are applied. So for example in an email containing:

# This should not be deleted
#
# Or trimmed
# It is code
####
Code code code

Everything below the first '#' is trimmed. That's a bit inconvenient, as many folks use comment markers to break sections of their code, sometimes even in multi-line strings for printing. Is there any chance this is a common enough issue that someone might have a moment to see if it could be improved? I've gotten as far as the regex where the matching happens, but I'm not sure how complex adding an exception for code blocks would be.

Thanks,
Zach

zlmarshall pushed a commit to zlmarshall/email_reply_trimmer that referenced this issue Nov 16, 2024
Addresses discourse#21

Adds two new regex classes identifying opening and closing code blocks
based on discourse rules for code blocks.

Creates two new patterns for matching either of those code block
patterns, and an additional pattern for matching both (since something
like "```" will match both opening and closing block patterns).

Allows delimiters within code blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant