One function

SlackMarkdownConverter in fla9ua/markdown_to_mrkdwn

The author described this change as Fix code block conversion issue #5\n\n- Add code block state tracking\n- Skip conversion inside code blocks\n- Add related test cases. It counts as a record because the check below fails on the code as it stood at a016004e3 and passes on 9902c72dc, with nothing else changed between the two runs.

Fix saved2025-01-25
Sharing licenceMIT · LICENSE
Change size+10 0

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

1515 encoding (str): The character encoding to use for the conversion. Default is 'utf-8'.
1616 """
1717 self.encoding = encoding
18+ self.in_code_block = False
1819 self.patterns: List[Tuple[str, str]] = [
1920 (r"^(\s*)- (.+)", r"\1• \2"), # Unordered list
2021 (r"!\[.*?\]\((.+?)\)", r"<\1>"), # Images to URL
6667 Returns:
6768 str: The converted line in Slack's mrkdwn format.
6869 """
70+ # Toggle code block state
71+ if line.startswith("```"):
72+ self.in_code_block = not self.in_code_block
73+ return line
74+
75+ # Skip conversion if inside code block
76+ if self.in_code_block:
77+ return line
78+
6979 for pattern, replacement in self.patterns:
7080 line = re.sub(pattern, replacement, line, flags=re.MULTILINE)
7181

The check that tells the two apart

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

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 ita016004e39578d9c1405ae12f002833f7eaf15c5
Broken version dated2025-01-03
Modulemarkdown_to_mrkdwn.converter
Units changedSlackMarkdownConverter
Fingerprint238968471d3cb282
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