From c13ae4c9a23f1046977a64e1eddc334ad16e20d0 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Thu, 19 Jun 2025 15:00:04 +0200 Subject: [PATCH] refactor: clean up code --- renderer/slide_break.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/renderer/slide_break.py b/renderer/slide_break.py index 84bde86..f8f4c04 100644 --- a/renderer/slide_break.py +++ b/renderer/slide_break.py @@ -1,4 +1,3 @@ - import re from mistletoe.block_token import BlockToken, tokenize @@ -7,23 +6,23 @@ from mistletoe.block_token import BlockToken, tokenize class SlideBreak(BlockToken): @staticmethod def start(line): - return re.match(r"^\s*---.*$", line) + return re.match(r"^---.*$", line) @classmethod def read(cls, lines): child_lines = [] - first_line = next(lines) # Consume the line that started the slide break + first_line = next(lines) # Consume the line that started the slide break - match = re.match(r"^\s*---\s*(.*)\s*.*$", first_line) - attribute = match.group(1) if match.group(1) else None + match = re.match(r"^---(.*)$", first_line) + attribute = match.group(1).strip() if match.group(1) else None # We have to work with peak here, since a normal for loop would already # consume the next line, which might be a `---` line that marks the # beginning of a new slide as well next_line = lines.peek() while next_line is not None: - if re.match(r"^\s*---.*$", next_line) : - break + if cls.start(next_line): + break else: child_lines.append(next(lines)) next_line = lines.peek()