Whole file

seratch/ChatGPT-in-Slack

The author described this change as Fix bug with markdown translation within multiline code blocks and add unit tests. It counts as a record because the checks below fail on the code as it stood at bc6cc3760 and pass on e783f676f, with nothing else changed between the two runs.

Fix saved2023-05-07
Sharing licenceMIT · LICENSE
Change size+2 2

What the code was meant to do, written into the code itself as a save note

Fix bug with markdown translation within multiline code blocks and add unit tests

The change

55 # See also: https://api.slack.com/reference/surfaces/formatting#basics
66 def slack_to_markdown(content: str) -> str:
77 # Split the input string into parts based on code blocks and inline code
8- parts = re.split(r"(```.+?```|`[^`\n]+?`)", content)
8+ parts = re.split(r"(?s)(```.+?```|`[^`\n]+?`)", content)
99
1010 # Apply the bold, italic, and strikethrough formatting to text not within code
1111 result = ""
2727 # See also: https://api.slack.com/reference/surfaces/formatting#basics
2828 def markdown_to_slack(content: str) -> str:
2929 # Split the input string into parts based on code blocks and inline code
30- parts = re.split(r"(```.+?```|`[^`\n]+?`)", content)
30+ parts = re.split(r"(?s)(```.+?```|`[^`\n]+?`)", content)
3131
3232 # Apply the bold, italic, and strikethrough formatting to text not within code
3333 result = ""

The check that tells the two apart

failpass·tests/markdown_test.py::test_markdown_to_slack
failpass·tests/markdown_test.py::test_slack_to_markdown

Check file tests/markdown_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itbc6cc37603c882e4b6a07c05339ba00c09edc03c
Broken version dated2023-05-07
Moduleapp.markdown
Units changedmarkdown_to_slack, slack_to_markdown
Fingerprint6d52002e7b3221c9
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.