refactor: clean up code
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from mistletoe.block_token import BlockToken, tokenize
|
from mistletoe.block_token import BlockToken, tokenize
|
||||||
@@ -7,23 +6,23 @@ from mistletoe.block_token import BlockToken, tokenize
|
|||||||
class SlideBreak(BlockToken):
|
class SlideBreak(BlockToken):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start(line):
|
def start(line):
|
||||||
return re.match(r"^\s*---.*$", line)
|
return re.match(r"^---.*$", line)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def read(cls, lines):
|
def read(cls, lines):
|
||||||
child_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)
|
match = re.match(r"^---(.*)$", first_line)
|
||||||
attribute = match.group(1) if match.group(1) else None
|
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
|
# 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
|
# consume the next line, which might be a `---` line that marks the
|
||||||
# beginning of a new slide as well
|
# beginning of a new slide as well
|
||||||
next_line = lines.peek()
|
next_line = lines.peek()
|
||||||
while next_line is not None:
|
while next_line is not None:
|
||||||
if re.match(r"^\s*---.*$", next_line) :
|
if cls.start(next_line):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
child_lines.append(next(lines))
|
child_lines.append(next(lines))
|
||||||
next_line = lines.peek()
|
next_line = lines.peek()
|
||||||
|
|||||||
Reference in New Issue
Block a user