style: reformat code with ruff
This commit is contained in:
+4
-2
@@ -9,7 +9,9 @@ class SpanComment(SpanToken):
|
||||
Coment span token (% Eiersalat).
|
||||
Identifies a comment in text.
|
||||
"""
|
||||
pattern = re.compile(r'(%.*\n?)')
|
||||
|
||||
pattern = re.compile(r"(%.*\n?)")
|
||||
|
||||
|
||||
class BlockComment(BlockToken):
|
||||
@staticmethod
|
||||
@@ -19,4 +21,4 @@ class BlockComment(BlockToken):
|
||||
@classmethod
|
||||
def read(cls, lines):
|
||||
next(lines)
|
||||
return None
|
||||
return None
|
||||
|
||||
+2
-1
@@ -8,4 +8,5 @@ class Dash(SpanToken):
|
||||
Dash span token ( - ).
|
||||
Identifies a dash in a text.
|
||||
"""
|
||||
pattern = re.compile(r'(\s-\s)')
|
||||
|
||||
pattern = re.compile(r"(\s-\s)")
|
||||
|
||||
@@ -146,9 +146,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
||||
else:
|
||||
type = token.tagtype
|
||||
|
||||
return self.render_tag_helper(
|
||||
type, self.render_inner(token), self.margin_id, self.margin_anchor_id
|
||||
)
|
||||
return self.render_tag_helper(type, self.render_inner(token), self.margin_id, self.margin_anchor_id)
|
||||
|
||||
def render_halfwidth_spaces(self, token):
|
||||
return f"{token.first}. {token.second}."
|
||||
|
||||
@@ -10,7 +10,6 @@ from renderer.underline import Underline
|
||||
|
||||
|
||||
class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
Dash,
|
||||
@@ -23,7 +22,7 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
||||
NonbreakingSpaces,
|
||||
NonbreakingSpacesDots,
|
||||
)
|
||||
|
||||
|
||||
def render_document(self, token):
|
||||
self.footnotes.update(token.footnotes)
|
||||
return self.render_inner(token)
|
||||
@@ -32,25 +31,24 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
||||
return " -- "
|
||||
|
||||
def render_block_comment(self, token):
|
||||
return "" # TODO propagate comments to the LaTeX document
|
||||
return "" # TODO propagate comments to the LaTeX document
|
||||
|
||||
def render_span_comment(self, token):
|
||||
return "" # TODO propagate comments to the LaTeX document
|
||||
return "" # TODO propagate comments to the LaTeX document
|
||||
|
||||
def render_quote(self, token):
|
||||
return fr"\enquote{{{self.render_inner(token)}}}"
|
||||
return rf"\enquote{{{self.render_inner(token)}}}"
|
||||
|
||||
def render_emphasis(self, token):
|
||||
return fr"\emph{{{self.render_inner(token)}}}"
|
||||
return rf"\emph{{{self.render_inner(token)}}}"
|
||||
|
||||
def render_underline(self, token):
|
||||
return fr"\underline{{{self.render_inner(token)}}}"
|
||||
return rf"\underline{{{self.render_inner(token)}}}"
|
||||
|
||||
def render_thematic_break(self, token):
|
||||
return ""
|
||||
|
||||
def render_tag(self, token): # noqa: C901
|
||||
|
||||
tagtype = None
|
||||
|
||||
match token.tagtype:
|
||||
@@ -81,7 +79,7 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
||||
case _:
|
||||
tagtype = "Margin"
|
||||
|
||||
return fr"\{tagtype}{{{self.render_inner(token)}}}"
|
||||
return rf"\{tagtype}{{{self.render_inner(token)}}}"
|
||||
|
||||
def render_halfwidth_spaces(self, token):
|
||||
return f"{token.first}.\,{token.second}."
|
||||
@@ -90,8 +88,5 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
||||
return f"{token.first}~{token.second}"
|
||||
|
||||
def render_nonbreaking_spaces_dots(self, token):
|
||||
lookup = {
|
||||
"" : "",
|
||||
" " : "~"
|
||||
}
|
||||
return f"{lookup[token.first]}{token.second}{lookup[token.third]}"
|
||||
lookup = {"": "", " ": "~"}
|
||||
return f"{lookup[token.first]}{token.second}{lookup[token.third]}"
|
||||
|
||||
@@ -8,11 +8,9 @@ class HalfwidthSpaces(SpanToken):
|
||||
Insert halfwidth space into span token (Z. B.)
|
||||
Identifies "z.B.", "d.h." and "D.h." with and without space in between.
|
||||
"""
|
||||
|
||||
pattern = re.compile(r"\b(z|Z|d|D)\.\s?(B|h)\.")
|
||||
|
||||
def __init__(self, match_object):
|
||||
self.first = match_object.group(1)
|
||||
self.second = match_object.group(2)
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-5
@@ -8,8 +8,9 @@ class Morse(SpanToken):
|
||||
Morse code span token ("[morse:moe]").
|
||||
Generates morse code from a text.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def convert_to_morse_code(text):
|
||||
def convert_to_morse_code(text):
|
||||
dit = 1
|
||||
dah = 2
|
||||
space = 3
|
||||
@@ -74,16 +75,16 @@ class Morse(SpanToken):
|
||||
"bk": [dah, dit, dit, dit, dah, dit, dah],
|
||||
"sk": [dit, dit, dit, dah, dit, dah],
|
||||
"correction": [dit, dit, dit, dit, dit, dit, dit, dit],
|
||||
" ": [space]
|
||||
" ": [space],
|
||||
}
|
||||
|
||||
|
||||
result = []
|
||||
|
||||
for char in text:
|
||||
if char.lower() in morse_code:
|
||||
result.append(morse_code[char.lower()])
|
||||
|
||||
|
||||
return result
|
||||
|
||||
parse_inner = False
|
||||
pattern = re.compile(r'"\[morse:\s*(.+)\]"')
|
||||
pattern = re.compile(r'"\[morse:\s*(.+)\]"')
|
||||
|
||||
@@ -8,23 +8,23 @@ class NonbreakingSpaces(SpanToken):
|
||||
Insert unbreakable space into span token (§ 3)
|
||||
Identifies "§$number", "Abs.$number", "Klasse [A,E,N]" w/ and without space between.
|
||||
"""
|
||||
|
||||
pattern = re.compile(r"(§|Abs\.|Klasse)\s?(\d|[NEA])")
|
||||
|
||||
def __init__(self, match_object):
|
||||
self.first = match_object.group(1)
|
||||
self.second = match_object.group(2)
|
||||
|
||||
|
||||
class NonbreakingSpacesDots(SpanToken):
|
||||
"""
|
||||
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):
|
||||
self.first = match_object.group(1)
|
||||
self.second = match_object.group(2)
|
||||
self.third = match_object.group(3)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,4 +8,5 @@ class Quote(SpanToken):
|
||||
Quote span token ("Eiersalat").
|
||||
Identifies quoted text.
|
||||
"""
|
||||
|
||||
pattern = re.compile(r'"([^"]+)"')
|
||||
|
||||
@@ -8,8 +8,8 @@ class References(SpanToken):
|
||||
Resolve references for html
|
||||
Identifies "[ref:$]"
|
||||
"""
|
||||
|
||||
pattern = re.compile(r"\[ref\:(\S+)\]")
|
||||
|
||||
def __init__(self, match_object):
|
||||
self.first = match_object.group(1)
|
||||
|
||||
|
||||
@@ -8,4 +8,5 @@ class Underline(SpanToken):
|
||||
Underline span token (<u>Untersrich</u>).
|
||||
Identifies underlined text.
|
||||
"""
|
||||
pattern = re.compile(r'<u>(.+)</u>')
|
||||
|
||||
pattern = re.compile(r"<u>(.+)</u>")
|
||||
|
||||
@@ -4,25 +4,24 @@ from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||||
from renderer.fifty_ohm_latex_renderer import FiftyOhmLaTeXRenderer
|
||||
|
||||
|
||||
def test_comment_html() :
|
||||
|
||||
def test_comment_html():
|
||||
assertions = {
|
||||
"%Comment\nBar" : "<p>Bar</p>\n",
|
||||
"%Comment\nBar": "<p>Bar</p>\n",
|
||||
# TODO: This test is not working as expected. The comment should be removed
|
||||
#"%Comment\n" : "a",
|
||||
"Foo\n%Comment\nBar" : "<p>Foo\nBar</p>\n",
|
||||
# "%Comment\n" : "a",
|
||||
"Foo\n%Comment\nBar": "<p>Foo\nBar</p>\n",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
|
||||
|
||||
def test_comment_latex() :
|
||||
|
||||
def test_comment_latex():
|
||||
assertions = {
|
||||
"%Comment\nBar" : "\nBar\n",
|
||||
"%Comment\nBar": "\nBar\n",
|
||||
# TODO: This test is not working as expected. The comment should be removed
|
||||
#"%Comment\n" : "a",
|
||||
"Foo\n%Comment\nBar" : "\nFoo\nBar\n",
|
||||
# "%Comment\n" : "a",
|
||||
"Foo\n%Comment\nBar": "\nFoo\nBar\n",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
|
||||
+4
-5
@@ -5,19 +5,18 @@ from renderer.fifty_ohm_latex_renderer import FiftyOhmLaTeXRenderer
|
||||
from test.util import paragraph
|
||||
|
||||
|
||||
def test_dash_html() :
|
||||
|
||||
def test_dash_html():
|
||||
assertions = {
|
||||
"Foo - Bar" : "Foo – Bar",
|
||||
"Foo - Bar": "Foo – Bar",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == paragraph(assertions[assertion])
|
||||
|
||||
def test_dash_latex() :
|
||||
|
||||
def test_dash_latex():
|
||||
assertions = {
|
||||
"Foo - Bar" : "\nFoo -- Bar\n",
|
||||
"Foo - Bar": "\nFoo -- Bar\n",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
|
||||
+2
-4
@@ -1,14 +1,12 @@
|
||||
|
||||
import mistletoe
|
||||
|
||||
from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||||
|
||||
|
||||
def test_html(capsys) :
|
||||
|
||||
def test_html(capsys):
|
||||
with capsys.disabled():
|
||||
with open("test/acceptanceTest.md") as file:
|
||||
content = file.read()
|
||||
output = mistletoe.markdown(content, FiftyOhmHtmlRenderer)
|
||||
with open("test/acceptanceTest.html", "w") as output_file:
|
||||
output_file.write(output)
|
||||
output_file.write(output)
|
||||
|
||||
@@ -11,12 +11,13 @@ def test_paragraph_html():
|
||||
|
||||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(target)
|
||||
|
||||
|
||||
def test_three_points_html():
|
||||
assertions = {
|
||||
"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"
|
||||
"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",
|
||||
}
|
||||
|
||||
for key, value in assertions.items():
|
||||
@@ -29,39 +30,42 @@ def test_absatz_html():
|
||||
|
||||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(target)
|
||||
|
||||
|
||||
def test_class_html():
|
||||
input = "Ich lerne für Klasse A, Klasse E und Klasse N."
|
||||
target = "Ich lerne für Klasse A, Klasse E und Klasse N."
|
||||
|
||||
assert mistletoe.markdown(input, FiftyOhmHtmlRenderer) == paragraph(target)
|
||||
|
||||
|
||||
def test_paragraph_latex():
|
||||
input = "Der Test befindet sich unter §2 vielleicht aber auch § 3."
|
||||
target = "\nDer Test befindet sich unter §~2 vielleicht aber auch §~3.\n"
|
||||
|
||||
assert mistletoe.markdown(input, FiftyOhmLaTeXRenderer) == target
|
||||
|
||||
|
||||
def test_three_points_latex():
|
||||
assertions = {
|
||||
"Heute hatte ich ... zum Mittagessen." : "\nHeute hatte ich~...~zum Mittagessen.\n",
|
||||
"Niemals hätte ich gedacht, dass...ich ...nicht kann." : "\nNiemals hätte ich gedacht, dass...ich~...nicht kann.\n",
|
||||
"Oh nein ...ein Pinguin." : "\nOh nein~...ein Pinguin.\n",
|
||||
"Haha .. . Hahaha" : "\nHaha .. . Hahaha\n"
|
||||
"Heute hatte ich ... zum Mittagessen.": "\nHeute hatte ich~...~zum Mittagessen.\n",
|
||||
"Niemals hätte ich gedacht, dass...ich ...nicht kann.": "\nNiemals hätte ich gedacht, dass...ich~...nicht kann.\n",
|
||||
"Oh nein ...ein Pinguin.": "\nOh nein~...ein Pinguin.\n",
|
||||
"Haha .. . Hahaha": "\nHaha .. . Hahaha\n",
|
||||
}
|
||||
|
||||
for key, value in assertions.items():
|
||||
assert mistletoe.markdown(key, FiftyOhmLaTeXRenderer) == value
|
||||
|
||||
|
||||
def test_absatz_latex():
|
||||
input = "Der Test befindet sich unter Abs.2 vielleicht aber auch Abs. 3."
|
||||
target = "\nDer Test befindet sich unter Abs.~2 vielleicht aber auch Abs.~3.\n"
|
||||
|
||||
assert mistletoe.markdown(input, FiftyOhmLaTeXRenderer) == target
|
||||
|
||||
|
||||
def test_class_latex():
|
||||
input = "Ich lerne für Klasse A, Klasse E und Klasse N."
|
||||
target = "\nIch lerne für Klasse~A, Klasse~E und Klasse~N.\n"
|
||||
|
||||
assert mistletoe.markdown(input, FiftyOhmLaTeXRenderer) == target
|
||||
|
||||
|
||||
|
||||
+14
-15
@@ -5,29 +5,28 @@ from renderer.fifty_ohm_latex_renderer import FiftyOhmLaTeXRenderer
|
||||
from test.util import paragraph
|
||||
|
||||
|
||||
def test_quote_html() :
|
||||
|
||||
def test_quote_html():
|
||||
assertions = {
|
||||
'"quote"' : '„quote“',
|
||||
'" quote "' : '„ quote “',
|
||||
'"quote" "' : '„quote“ "',
|
||||
'"quo te1" filltext "qu ot e2"' : '„quo te1“ filltext „qu ot e2“',
|
||||
'"quo *te1*" filltext "qu ot e2"' : '„quo <em>te1</em>“ filltext „qu ot e2“',
|
||||
'""' : '""',
|
||||
'"quote"': "„quote“",
|
||||
'" quote "': "„ quote “",
|
||||
'"quote" "': '„quote“ "',
|
||||
'"quo te1" filltext "qu ot e2"': "„quo te1“ filltext „qu ot e2“",
|
||||
'"quo *te1*" filltext "qu ot e2"': "„quo <em>te1</em>“ filltext „qu ot e2“",
|
||||
'""': '""',
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == paragraph(assertions[assertion])
|
||||
|
||||
def test_quote_latex() :
|
||||
|
||||
def test_quote_latex():
|
||||
assertions = {
|
||||
'"quote"' : '\n\enquote{quote}\n',
|
||||
'" quote "' : '\n\enquote{ quote }\n',
|
||||
'"quote" "' : '\n\enquote{quote} "\n',
|
||||
'"quo te1" filltext "qu ot e2"' : '\n\enquote{quo te1} filltext \enquote{qu ot e2}\n',
|
||||
'"quo *te1*" filltext "qu ot e2"' : '\n\enquote{quo \emph{te1}} filltext \enquote{qu ot e2}\n',
|
||||
'""' : '\n""\n',
|
||||
'"quote"': "\n\enquote{quote}\n",
|
||||
'" quote "': "\n\enquote{ quote }\n",
|
||||
'"quote" "': '\n\enquote{quote} "\n',
|
||||
'"quo te1" filltext "qu ot e2"': "\n\enquote{quo te1} filltext \enquote{qu ot e2}\n",
|
||||
'"quo *te1*" filltext "qu ot e2"': "\n\enquote{quo \emph{te1}} filltext \enquote{qu ot e2}\n",
|
||||
'""': '\n""\n',
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
|
||||
+52
-41
@@ -4,82 +4,93 @@ from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||||
from renderer.fifty_ohm_latex_renderer import FiftyOhmLaTeXRenderer
|
||||
|
||||
|
||||
|
||||
def test_thematic_break_html() :
|
||||
def test_thematic_break_html():
|
||||
assertions = {
|
||||
"---" : '<a id="margin_1"></a>\n',
|
||||
"---\n---" : '<a id="margin_1"></a>\n<a id="margin_2"></a>\n',
|
||||
"---": '<a id="margin_1"></a>\n',
|
||||
"---\n---": '<a id="margin_1"></a>\n<a id="margin_2"></a>\n',
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
|
||||
|
||||
def test_tag_html() :
|
||||
|
||||
def test_tag_html():
|
||||
assertions = {
|
||||
"<margin>\nFoo\n</margin>" : FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",1,0)+'\n',
|
||||
"<indepth>\nFoo\n</indepth>" : FiftyOhmHtmlRenderer.render_tag_helper("indepth","<p>Foo</p>",1,0)+'\n',
|
||||
"<webmargin>\nFoo\n</webmargin>" : FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",1,0)+'\n',
|
||||
"<tip>\nFoo\n</tip>" : FiftyOhmHtmlRenderer.render_tag_helper("tip","<p>Foo</p>",1,0)+'\n',
|
||||
"<webtip>\nFoo\n</webtip>" : FiftyOhmHtmlRenderer.render_tag_helper("tip","<p>Foo</p>",1,0)+'\n',
|
||||
"<webindepth>\nFoo\n</webindepth>" : FiftyOhmHtmlRenderer.render_tag_helper("indepth","<p>Foo</p>",1,0)+'\n',
|
||||
"<unit>\nFoo\n</unit>" : FiftyOhmHtmlRenderer.render_tag_helper("unit","<p>Foo</p>",1,0)+'\n',
|
||||
"<danger>\nFoo\n</danger>" : FiftyOhmHtmlRenderer.render_tag_helper("danger","<p>Foo</p>",1,0)+'\n',
|
||||
"<webonly>\nFoo\n</webonly>" : '<p>Foo</p>\n',
|
||||
"<latexonly>\nFoo\n</latexonly>" : "",
|
||||
"<margin>\nFoo\n</margin>": FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<indepth>\nFoo\n</indepth>": FiftyOhmHtmlRenderer.render_tag_helper("indepth", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<webmargin>\nFoo\n</webmargin>": FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<tip>\nFoo\n</tip>": FiftyOhmHtmlRenderer.render_tag_helper("tip", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<webtip>\nFoo\n</webtip>": FiftyOhmHtmlRenderer.render_tag_helper("tip", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<webindepth>\nFoo\n</webindepth>": FiftyOhmHtmlRenderer.render_tag_helper("indepth", "<p>Foo</p>", 1, 0)
|
||||
+ "\n",
|
||||
"<unit>\nFoo\n</unit>": FiftyOhmHtmlRenderer.render_tag_helper("unit", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<danger>\nFoo\n</danger>": FiftyOhmHtmlRenderer.render_tag_helper("danger", "<p>Foo</p>", 1, 0) + "\n",
|
||||
"<webonly>\nFoo\n</webonly>": "<p>Foo</p>\n",
|
||||
"<latexonly>\nFoo\n</latexonly>": "",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
|
||||
|
||||
def test_thematic_break_and_tag_html() :
|
||||
|
||||
def test_thematic_break_and_tag_html():
|
||||
assertions = {
|
||||
"---\n<margin>\nFoo\n</margin>" : '<a id="margin_1"></a>\n'+FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",1,1)+'\n',
|
||||
"---\n<margin>\nFoo\n</margin>\n<margin>\nFoo\n</margin>" : '<a id="margin_1"></a>\n'+FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",1,1)+'\n'+FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",2,1)+'\n',
|
||||
"---\n<margin>\nFoo\n</margin>\n---\n<margin>\nFoo\n</margin>" : '<a id="margin_1"></a>\n'+FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",1,1)+'\n<a id="margin_2"></a>\n'+FiftyOhmHtmlRenderer.render_tag_helper("margin","<p>Foo</p>",2,2)+'\n',
|
||||
"---\n<margin>\nFoo\n</margin>": '<a id="margin_1"></a>\n'
|
||||
+ FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 1, 1)
|
||||
+ "\n",
|
||||
"---\n<margin>\nFoo\n</margin>\n<margin>\nFoo\n</margin>": '<a id="margin_1"></a>\n'
|
||||
+ FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 1, 1)
|
||||
+ "\n"
|
||||
+ FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 2, 1)
|
||||
+ "\n",
|
||||
"---\n<margin>\nFoo\n</margin>\n---\n<margin>\nFoo\n</margin>": '<a id="margin_1"></a>\n'
|
||||
+ FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 1, 1)
|
||||
+ '\n<a id="margin_2"></a>\n'
|
||||
+ FiftyOhmHtmlRenderer.render_tag_helper("margin", "<p>Foo</p>", 2, 2)
|
||||
+ "\n",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
|
||||
|
||||
def test_thematic_break_latex() :
|
||||
|
||||
def test_thematic_break_latex():
|
||||
assertions = {
|
||||
"---" : '',
|
||||
"---\n---" : '',
|
||||
"---": "",
|
||||
"---\n---": "",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmLaTeXRenderer) == assertions[assertion]
|
||||
|
||||
def test_tag_latex() :
|
||||
|
||||
def test_tag_latex():
|
||||
assertions = {
|
||||
"<margin>\nFoo\n</margin>" : "\Margin{\nFoo\n}",
|
||||
"<danger>\nFoo\n</danger>" : "\MarginDanger{\nFoo\n}",
|
||||
"<warning>\nFoo\n</warning>" : "\MarginWarning{\nFoo\n}",
|
||||
"<attention>\nFoo\n</attention>" : "\MarginAttention{\nFoo\n}",
|
||||
"<tip>\nFoo\n</tip>" : "\MarginTip{\nFoo\n}",
|
||||
"<webtip>\nFoo\n</webtip>" : "\WebTip{\nFoo\n}",
|
||||
"<unit>\nFoo\n</unit>" : "\MarginUnit{\nFoo\n}",
|
||||
"<indepth>\nFoo\n</indepth>" : "\MarginInDepth{\nFoo\n}",
|
||||
"<webindepth>\nFoo\n</webindepth>" : "\MarginWebInDepth{\nFoo\n}",
|
||||
"<webmargin>\nFoo\n</webmargin>" : "\WebMargin{\nFoo\n}",
|
||||
"<fullwidth>\nFoo\n</fullwidth>" : "\FullWidth{\nFoo\n}",
|
||||
"<latexonly>\nFoo\n</latexonly>" : "\nFoo\n",
|
||||
"<webonly>\nFoo\n</webonly>" : "",
|
||||
"<margin>\nFoo\n</margin>": "\Margin{\nFoo\n}",
|
||||
"<danger>\nFoo\n</danger>": "\MarginDanger{\nFoo\n}",
|
||||
"<warning>\nFoo\n</warning>": "\MarginWarning{\nFoo\n}",
|
||||
"<attention>\nFoo\n</attention>": "\MarginAttention{\nFoo\n}",
|
||||
"<tip>\nFoo\n</tip>": "\MarginTip{\nFoo\n}",
|
||||
"<webtip>\nFoo\n</webtip>": "\WebTip{\nFoo\n}",
|
||||
"<unit>\nFoo\n</unit>": "\MarginUnit{\nFoo\n}",
|
||||
"<indepth>\nFoo\n</indepth>": "\MarginInDepth{\nFoo\n}",
|
||||
"<webindepth>\nFoo\n</webindepth>": "\MarginWebInDepth{\nFoo\n}",
|
||||
"<webmargin>\nFoo\n</webmargin>": "\WebMargin{\nFoo\n}",
|
||||
"<fullwidth>\nFoo\n</fullwidth>": "\FullWidth{\nFoo\n}",
|
||||
"<latexonly>\nFoo\n</latexonly>": "\nFoo\n",
|
||||
"<webonly>\nFoo\n</webonly>": "",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmLaTeXRenderer) == assertions[assertion]
|
||||
|
||||
def test_thematic_break_and_tag_latex() :
|
||||
|
||||
def test_thematic_break_and_tag_latex():
|
||||
assertions = {
|
||||
"---\n<margin>\nFoo\n</margin>" : "\Margin{\nFoo\n}",
|
||||
"---\n<margin>\nFoo\n</margin>\n<margin>\nFoo\n</margin>" : "\Margin{\nFoo\n}\Margin{\nFoo\n}",
|
||||
"---\n<margin>\nFoo\n</margin>\n---\n<margin>\nFoo\n</margin>" : "\Margin{\nFoo\n}\Margin{\nFoo\n}",
|
||||
"---\n<margin>\nFoo\n</margin>": "\Margin{\nFoo\n}",
|
||||
"---\n<margin>\nFoo\n</margin>\n<margin>\nFoo\n</margin>": "\Margin{\nFoo\n}\Margin{\nFoo\n}",
|
||||
"---\n<margin>\nFoo\n</margin>\n---\n<margin>\nFoo\n</margin>": "\Margin{\nFoo\n}\Margin{\nFoo\n}",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmLaTeXRenderer) == assertions[assertion]
|
||||
assert mistletoe.markdown(assertion, FiftyOhmLaTeXRenderer) == assertions[assertion]
|
||||
|
||||
@@ -5,23 +5,22 @@ from renderer.fifty_ohm_latex_renderer import FiftyOhmLaTeXRenderer
|
||||
from test.util import paragraph
|
||||
|
||||
|
||||
def test_underline_html() :
|
||||
|
||||
def test_underline_html():
|
||||
assertions = {
|
||||
"<u>Text</u>" : "<u>Text</u>",
|
||||
"<u> Text Text </u>" : "<u> Text Text </u>",
|
||||
"<u> Text *Text* </u>" : "<u> Text <em>Text</em> </u>",
|
||||
"<u>Text</u>": "<u>Text</u>",
|
||||
"<u> Text Text </u>": "<u> Text Text </u>",
|
||||
"<u> Text *Text* </u>": "<u> Text <em>Text</em> </u>",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == paragraph(assertions[assertion])
|
||||
|
||||
def test_underline_latex() :
|
||||
|
||||
def test_underline_latex():
|
||||
assertions = {
|
||||
"<u>Text</u>" : "\n\\underline{Text}\n",
|
||||
"<u> Text Text </u>" : "\n\\underline{ Text Text }\n",
|
||||
"<u> Text *Text* </u>" : "\n\\underline{ Text \emph{Text} }\n",
|
||||
"<u>Text</u>": "\n\\underline{Text}\n",
|
||||
"<u> Text Text </u>": "\n\\underline{ Text Text }\n",
|
||||
"<u> Text *Text* </u>": "\n\\underline{ Text \emph{Text} }\n",
|
||||
}
|
||||
|
||||
for assertion in assertions:
|
||||
|
||||
Reference in New Issue
Block a user