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

Fix markdown block quote truncation #1457

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

RobertSzefler
Copy link
Contributor

No description provided.

@RobertSzefler RobertSzefler force-pushed the fix/main-1729/slack-markdown-truncation branch 2 times, most recently from 8a3d4a5 to 2331dcf Compare June 14, 2024 19:22
@RobertSzefler RobertSzefler requested a review from arikalon1 June 14, 2024 19:23
@RobertSzefler RobertSzefler force-pushed the fix/main-1729/slack-markdown-truncation branch 3 times, most recently from 74d5c93 to 426f3f0 Compare June 14, 2024 19:34
@@ -71,6 +71,8 @@ botocore = "1.31.72"
boto3 = "1.28.72"
requests = "^2.32.3"
certifi = "^2023.7.22"
regex = "2024.5.15"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This because stdlib re does not support reverse search (regex.REVERSE) up to Python 3.12

@@ -71,6 +71,8 @@ botocore = "1.31.72"
boto3 = "1.28.72"
requests = "^2.32.3"
certifi = "^2023.7.22"
regex = "2024.5.15"
more_itertools = { version = "^10.3", python = "<3.12" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This because batched appeared in stdlib itertools only in Python 3.12

@RobertSzefler RobertSzefler force-pushed the fix/main-1729/slack-markdown-truncation branch 2 times, most recently from ffb30c6 to 8eb1169 Compare June 18, 2024 14:02
@RobertSzefler RobertSzefler force-pushed the fix/main-1729/slack-markdown-truncation branch from 8eb1169 to c721262 Compare July 8, 2024 08:12
@@ -58,6 +58,10 @@ def apply_length_limit(msg: str, max_length: int, truncator: Optional[str] = Non
truncator = truncator or "..."
return msg[: max_length - len(truncator)] + truncator

@staticmethod
def apply_length_limit_to_markdown(msg: str, max_length: int, truncator: str = "...") -> str:
return trim_markdown(msg, max_length, truncator)
Copy link
Contributor

@Avi-Robusta Avi-Robusta Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would put this in a try catch and if this thows an exception try to run apply_length_limit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@Avi-Robusta Avi-Robusta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM one comment

@RobertSzefler RobertSzefler merged commit d6d7230 into master Jul 9, 2024
6 checks passed
@RobertSzefler RobertSzefler deleted the fix/main-1729/slack-markdown-truncation branch July 9, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants