One function

SlackMarkdownConverter in fla9ua/markdown_to_mrkdwn

The author described this change as bug fix for bold in lists. It counts as a record because the check below fails on the code as it stood at c44c03d12 and passes on 19c20b40c, with nothing else changed between the two runs.

Fix saved2024-12-12
Sharing licenceMIT · LICENSE
Change size+5 9

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

A converter class to transform Markdown text into Slack's mrkdwn format. Attributes: encoding (str): The character encoding used for the conversion. patterns (List[Tuple[str, str]]): A list of regex patterns and their replacements.

The change

1616 """
1717 self.encoding = encoding
1818 self.patterns: List[Tuple[str, str]] = [
19+ (r"^(\s*)- (.+)", r"\1• \2"), # Unordered list
1920 (r"!\[.*?\]\((.+?)\)", r"<\1>"), # Images to URL
21+ (r"(?<!\*)\*([^*\n]+?)\*(?!\*)", r"_\1_ "), # Italic
2022 (r"^### (.+)$", r"*\1* "), # H3 as bold
2123 (r"^## (.+)$", r"*\1* "), # H2 as bold
2224 (r"^# (.+)$", r"*\1* "), # H1 as bold
23- (r"\*\*(.+?)\*\*", r"*\1* "), # Bold
25+ (r"(^|\s)~\*\*(.+?)\*\*(\s|$)", r"\1 *\2* \3"), # Bold with space handling
26+ (r"(?<!\*)\*\*(.+?)\*\*(?!\*)", r"*\1* "), # Bold
2427 (r"__(.+?)__", r"*\1* "), # Underline as bold
25- (r"(?<!\*)\*([^*\n]+?)\*(?!\*)", r"_\1_ "), # Italic
2628 (r"\[(.+?)\]\((.+?)\)", r"<\2|\1> "), # Links
2729 (r"`(.+?)`", r"`\1` "), # Inline code
28- (r"^- (.+)", r"• \1"), # Unordered list
2930 (r"^> (.+)", r"> \1"), # Blockquote
3031 (r"(---|\*\*\*|___)", r"──────────"), # Horizontal rule
3132 ]
6566 Returns:
6667 str: The converted line in Slack's mrkdwn format.
6768 """
68- original_line = line
6969 for pattern, replacement in self.patterns:
70- if line == original_line:
71- line = re.sub(r"^(\s*)- (.+)", r"\1• \2", line, flags=re.MULTILINE)
72- line = re.sub(pattern, replacement, line, flags=re.MULTILINE)
73- else:
74- break # Stop if any pattern has already changed the line
70+ line = re.sub(pattern, replacement, line, flags=re.MULTILINE)
7571
7672 return line.rstrip()

The check that tells the two apart

failpass·tests/test_converter.py::TestSlackMarkdownConverter::test_convert_bold_in_list

Check file tests/test_converter.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 itc44c03d12cc8bb745a941e28708b051e90160945
Broken version dated2024-12-05
Modulemarkdown_to_mrkdwn.converter
Units changedSlackMarkdownConverter
Fingerprint2808c9de80b3195c
Checked2026-08-18 by goldset/0.1

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

Other bugs found in fla9ua/markdown_to_mrkdwn