Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions marimo/_output/md_extensions/breakless_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,25 @@ def run(self, lines: list[str]) -> list[str]:
return lines

result_lines: list[str] = []
i = 0
append = result_lines.append # Localize for faster loop performance
match_list_start = self.LIST_START_PATTERN.match

while i < len(lines):
length = len(lines)
for i in range(length):
current_line = lines[i]
result_lines.append(current_line)
append(current_line)

# Check if we need to look ahead for a list
if i + 1 < len(lines):
if i + 1 < length:
next_line = lines[i + 1]

# If current line is not empty and next line starts a list
if (
current_line.strip() # Current line has content
and self.LIST_START_PATTERN.match(next_line)
and match_list_start(next_line)
): # Next line starts a list
# Check if there's already a blank line
if current_line.strip():
# Insert blank line to enable list interruption
result_lines.append("")

i += 1
# Insert blank line to enable list interruption
append("")

return result_lines

Expand Down