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.
Projectseratch/ChatGPT-in-Slack
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
| 5 | 5 | # See also: https://api.slack.com/reference/surfaces/formatting#basics | |
| 6 | 6 | def slack_to_markdown(content: str) -> str: | |
| 7 | 7 | # 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) | |
| 9 | 9 | ||
| 10 | 10 | # Apply the bold, italic, and strikethrough formatting to text not within code | |
| 11 | 11 | result = "" | |
| ⋯ | |||
| 27 | 27 | # See also: https://api.slack.com/reference/surfaces/formatting#basics | |
| 28 | 28 | def markdown_to_slack(content: str) -> str: | |
| 29 | 29 | # 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) | |
| 31 | 31 | ||
| 32 | 32 | # Apply the bold, italic, and strikethrough formatting to text not within code | |
| 33 | 33 | result = "" | |
The check that tells the two apart
fail→pass·tests/markdown_test.py::test_markdown_to_slack
fail→pass·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.