style: reformat code with ruff
This commit is contained in:
@@ -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