feature: add qso rendering

This commit is contained in:
Prof. Dr. Matthias Jung DL9MJ
2025-05-24 12:38:15 +02:00
parent ea370cc325
commit 735f47971f
3 changed files with 65 additions and 0 deletions
+10
View File
@@ -9,6 +9,7 @@ from .morse import Morse
from .nonbreaking_spaces import NonbreakingSpaces, NonbreakingSpacesDots
from .photo import Photo
from .picture import Picture
from .qso import Qso
from .question import Question
from .quote import Quote
from .references import References
@@ -43,6 +44,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
Picture,
Photo,
Table,
Qso,
)
self.question_renderer = question_renderer
@@ -155,6 +157,14 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
return self.render_tag_helper(type, self.render_inner(token), self.margin_id, self.margin_anchor_id)
def render_qso(self, token):
self.margin_id += 1
qso = ""
for child in token.children:
direction = "other" if child.received else "own"
qso += f'<div class="qso_{direction}">{self.render_inner(child)}</div>'
return self.render_tag_helper("qso", qso, self.margin_id, self.margin_anchor_id)
def render_halfwidth_spaces(self, token):
return f"{token.first}.&#8239;{token.second}."