Merge remote-tracking branch 'origin/main' into feature/references

This commit is contained in:
Johanna Riedel
2024-12-08 11:54:55 +01:00
8 changed files with 85 additions and 13 deletions
+11 -1
View File
@@ -1,7 +1,17 @@
import re
from mistletoe.block_token import BlockToken
from mistletoe.span_token import SpanToken
class Comment(BlockToken):
class SpanComment(SpanToken):
"""
Coment span token (% Eiersalat).
Identifies a comment in text.
"""
pattern = re.compile(r'(%.*\n?)')
class BlockComment(BlockToken):
@staticmethod
def start(line):
return line.startswith("%")
+11
View File
@@ -0,0 +1,11 @@
import re
from mistletoe.span_token import SpanToken
class Dash(SpanToken):
"""
Dash span token ( - ).
Identifies a dash in a text.
"""
pattern = re.compile(r'(\s-\s)')
+12 -5
View File
@@ -2,7 +2,8 @@ import textwrap
from mistletoe import HtmlRenderer
from renderer.comment import Comment
from renderer.comment import BlockComment, SpanComment
from renderer.dash import Dash
from renderer.halfwidth_spaces import HalfwidthSpaces
from renderer.nonbreaking_spaces import NonbreakingSpaces, NonbreakingSpacesDots
from renderer.quote import Quote
@@ -17,10 +18,16 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
margin_id = 0
def __init__(self):
super().__init__(Comment, Quote, Underline, Tag, HalfwidthSpaces, NonbreakingSpaces, NonbreakingSpacesDots, References)
super().__init__(Dash, BlockComment, SpanComment, Quote, Underline, Tag, HalfwidthSpaces, NonbreakingSpaces, NonbreakingSpacesDots, References)
def render_comment():
return None
def render_dash(self, token):
return " – "
def render_block_comment(self, token):
return ""
def render_span_comment(self, token):
return ""
def render_quote(self, token):
return f"„{self.render_inner(token)}“"
@@ -68,7 +75,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
if(token.tagtype == "webmargin"):
type = "margin"
elif(token.tagtype == "webtip"):
elif(token.tagtype == "webtipp"):
type = "tipp"
elif(token.tagtype == "webindepth"):
type = "indepth"
+13 -1
View File
@@ -2,12 +2,24 @@ import re
from mistletoe.block_token import BlockToken, tokenize
captures = [
"margin",
"indepth",
"webmargin",
"tipp",
"webtipp",
"webindepth",
"unit",
"danger",
"webonly",
"latexonly",
]
class Tag(BlockToken):
@staticmethod
def start(line):
return re.match(r"^\s*<[^>]+>", line)
return re.match(r"^\s*<("+"|".join(captures)+r")+>", line)
@classmethod
def read(cls, lines):