feat: parse questions von @dl9mj

This commit is contained in:
Tim Grelka
2025-02-16 21:44:45 +01:00
parent 04a20e6121
commit 9ea98a941d
5 changed files with 87 additions and 6 deletions
+24
View File
@@ -0,0 +1,24 @@
import re
from mistletoe.block_token import BlockToken
class Question(BlockToken):
@staticmethod
def start(line):
# Search for:
# [question:123]
return re.match(r"^\s*\[question:\d+\]", line)
@classmethod
def read(cls, lines):
first_line = next(lines)
question_number = re.match(r"^\s*\[question:(\d+)\]", first_line).group(1)
return question_number
@classmethod
def check_interrupts_paragraph(cls, lines):
return cls.start(lines.peek())
def __init__(self, match):
self.question_number = match