Merge remote-tracking branch 'origin/main' into feature/references
This commit is contained in:
@@ -18,7 +18,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
|||||||
margin_id = 0
|
margin_id = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(Dash, BlockComment, SpanComment, Quote, Underline, Tag, HalfwidthSpaces, NonbreakingSpaces, NonbreakingSpacesDots, References)
|
super().__init__(Dash, BlockComment, SpanComment, Quote, Underline, Tag, HalfwidthSpaces, NonbreakingSpaces, NonbreakingSpacesDots, HalfwidthSpaces, NonbreakingSpaces, NonbreakingSpacesDots, References)
|
||||||
|
|
||||||
def render_dash(self, token):
|
def render_dash(self, token):
|
||||||
return " – "
|
return " – "
|
||||||
@@ -97,7 +97,8 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
|||||||
return f"{token.first} {token.second}"
|
return f"{token.first} {token.second}"
|
||||||
|
|
||||||
def render_nonbreaking_spaces_dots(self, token):
|
def render_nonbreaking_spaces_dots(self, token):
|
||||||
return f" {token.first} "
|
lookup = {
|
||||||
|
"" : "",
|
||||||
def render_references(self, token, dest_id=0, chap_url="DeineMama.html"):
|
" " : " "
|
||||||
return f"<a href="{chap_url}#ref_{token.first}" onclick="highlightRef('{token.first}');">{dest_id}</a>"
|
}
|
||||||
|
return f"{lookup[token.first]}{token.second}{lookup[token.third]}"
|
||||||
@@ -7,7 +7,6 @@ class NonbreakingSpaces(SpanToken):
|
|||||||
"""
|
"""
|
||||||
Insert unbreakable space into span token (§ 3)
|
Insert unbreakable space into span token (§ 3)
|
||||||
Identifies "§$number", "Abs.$number", "Klasse [A,E,N]" w/ and w\ space between.
|
Identifies "§$number", "Abs.$number", "Klasse [A,E,N]" w/ and w\ space between.
|
||||||
Identifies "..." with and without leading and trailing space
|
|
||||||
"""
|
"""
|
||||||
pattern = re.compile(r"(§|Abs\.|Klasse)\s?(\d|[NEA])")
|
pattern = re.compile(r"(§|Abs\.|Klasse)\s?(\d|[NEA])")
|
||||||
|
|
||||||
@@ -16,10 +15,16 @@ class NonbreakingSpaces(SpanToken):
|
|||||||
self.second = match_object.group(2)
|
self.second = match_object.group(2)
|
||||||
|
|
||||||
class NonbreakingSpacesDots(SpanToken):
|
class NonbreakingSpacesDots(SpanToken):
|
||||||
pattern = re.compile(r"\s?(\.\.\.)\s?")
|
"""
|
||||||
|
Insert unbreakable space before and after "..." if there is a space
|
||||||
|
Identifies "..." with leading and/or trailing space
|
||||||
|
"""
|
||||||
|
pattern = re.compile(r"(\s?)(\.\.\.)(\s?)")
|
||||||
|
|
||||||
def __init__(self, match_object):
|
def __init__(self, match_object):
|
||||||
self.first = match_object.group(1)
|
self.first = match_object.group(1)
|
||||||
|
self.second = match_object.group(2)
|
||||||
|
self.third = match_object.group(3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,15 @@ def test_paragraph_html():
|
|||||||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(target)
|
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(target)
|
||||||
|
|
||||||
def test_three_points_html():
|
def test_three_points_html():
|
||||||
input = "Heute hatte ich ... zum Mittagessen."
|
assertions = {
|
||||||
target = "Heute hatte ich ... zum Mittagessen."
|
"Heute hatte ich ... zum Mittagessen." : "Heute hatte ich ... zum Mittagessen.",
|
||||||
|
"Niemals hätte ich gedacht, dass...ich ...nicht kann." : "Niemals hätte ich gedacht, dass...ich ...nicht kann.",
|
||||||
|
"Oh nein ...ein Pinguin." : "Oh nein ...ein Pinguin.",
|
||||||
|
"Haha .. . Hahaha" : "Haha .. . Hahaha"
|
||||||
|
}
|
||||||
|
|
||||||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(target)
|
for key, value in assertions.items():
|
||||||
|
assert mistletoe.markdown(key, FiftyOhmHtmlRenderer) == paragraph(value)
|
||||||
|
|
||||||
|
|
||||||
def test_absatz_html():
|
def test_absatz_html():
|
||||||
|
|||||||
Reference in New Issue
Block a user