refactor: converted to block token

This commit is contained in:
Prof. Dr. Matthias Jung DL9MJ
2025-06-24 22:04:42 +02:00
committed by Tim Grelka
parent 059ed59eaf
commit c2209c5cc2
3 changed files with 18 additions and 7 deletions
+16 -5
View File
@@ -1,13 +1,24 @@
import re
from mistletoe.span_token import SpanToken
from mistletoe.block_token import BlockToken
class Include(SpanToken):
class Include(BlockToken):
"""
Span token ("[include:ident]").
Block token ("[include:ident]").
Includes raw html or javascript code from a file with the given identifier.
"""
parse_inner = False
pattern = re.compile(r'\[include:\s*([^\]]+)\]')
@staticmethod
def start(line):
return re.match(r"^\s*\[include:\s*[^\]]+\]", line)
@classmethod
def read(cls, lines):
re.compile(r'')
line = next(lines) # Consume the line with the include directive
ident = re.match(r"^\s*\[include:\s*([^\]]+)\]", line).group(1)
return ident
def __init__(self, match):
self.ident = match