Merge branch 'main' into feature/slides
This commit is contained in:
@@ -8,6 +8,7 @@ from mistletoe import Document, HtmlRenderer
|
||||
from .comment import BlockComment
|
||||
from .dash import Dash
|
||||
from .halfwidth_spaces import HalfwidthSpaces
|
||||
from .include import Include
|
||||
from .morse import Morse
|
||||
from .nonbreaking_spaces import NonbreakingSpaces, NonbreakingSpacesDots
|
||||
from .photo import Photo
|
||||
@@ -30,7 +31,14 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
||||
section_url = "section.html"
|
||||
ref_id = 0
|
||||
|
||||
def __init__(self, *extras, question_renderer=None, picture_handler=None, photo_handler=None):
|
||||
def __init__(
|
||||
self,
|
||||
*extras,
|
||||
question_renderer=None,
|
||||
picture_handler=None,
|
||||
photo_handler=None,
|
||||
include_handler=None
|
||||
):
|
||||
|
||||
final_extras = chain(extras,(
|
||||
Dash,
|
||||
@@ -49,6 +57,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
||||
Photo,
|
||||
Table,
|
||||
Qso,
|
||||
Include,
|
||||
))
|
||||
|
||||
super().__init__(*final_extras)
|
||||
@@ -56,6 +65,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
||||
self.question_renderer = question_renderer
|
||||
self.picture_handler = picture_handler
|
||||
self.photo_handler = photo_handler
|
||||
self.include_handler = include_handler
|
||||
|
||||
def render_dash(self, token):
|
||||
return " – "
|
||||
@@ -233,3 +243,6 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
||||
table += "</table>"
|
||||
|
||||
return table
|
||||
|
||||
def render_include(self, token):
|
||||
return self.include_handler(token.ident)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import re
|
||||
|
||||
from mistletoe.block_token import BlockToken
|
||||
|
||||
|
||||
class Include(BlockToken):
|
||||
"""
|
||||
Block token ("[include:ident]").
|
||||
Includes raw html or javascript code from a file with the given identifier.
|
||||
"""
|
||||
|
||||
@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
|
||||
Reference in New Issue
Block a user