style: include new linter rules and fix files

This commit is contained in:
Tim Grelka
2025-07-03 17:23:46 +02:00
parent 433f4ba4ef
commit 09331b3a54
20 changed files with 64 additions and 56 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ def test_comment_latex():
assertions = {
"%Comment\nBar": "% Comment\n\nBar\n",
"%Comment\n": "% Comment\n",
"Foo 100 % Bar": "\nFoo 100 \% Bar\n",
"Foo 100 % Bar": "\nFoo 100 \\% Bar\n",
"Foo\n%Comment\nBar": "\nFoo\n% Comment\n\nBar\n",
}
+1 -1
View File
@@ -17,6 +17,6 @@ def test_halfwidth_space_html():
@pytest.mark.latex
def test_halfwidth_space_latex():
input = "Dies ist z.B. ein Test. D.h. hier sollten d.h. Spaces ersetzt worden sein."
target = "\nDies ist z.\,B. ein Test. D.\,h. hier sollten d.\,h. Spaces ersetzt worden sein.\n"
target = "\nDies ist z.\\,B. ein Test. D.\\,h. hier sollten d.\\,h. Spaces ersetzt worden sein.\n"
assert mistletoe.markdown(input, FiftyOhmLaTeXRenderer) == target
+1 -1
View File
@@ -15,4 +15,4 @@ def test_include_html():
with FiftyOhmHtmlRenderer(include_handler=test_function) as renderer:
for assertion in assertions:
assert renderer.render(Document(assertion)) == assertions[assertion]
assert renderer.render(Document(assertion)) == assertions[assertion]
+6 -6
View File
@@ -8,12 +8,12 @@ from test.util import paragraph
@pytest.mark.html
def test_morse_html():
assertions = {
'[morse:a]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
'[morse:a] abc [morse:a]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]])+ ' abc ' + FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
'[morse: a]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
'[morse: aaa]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2], [1, 2], [1, 2]]),
'[morse: a a]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2], [3], [1, 2]]),
'[morse: db0]': FiftyOhmHtmlRenderer.render_morse_helper([[2, 1, 1], [2, 1, 1, 1], [2, 2, 2, 2, 2]]),
"[morse:a]": FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
"[morse:a] abc [morse:a]": f"{FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]])} abc {FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]])}", # noqa: E501
"[morse: a]": FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
"[morse: aaa]": FiftyOhmHtmlRenderer.render_morse_helper([[1, 2], [1, 2], [1, 2]]),
"[morse: a a]": FiftyOhmHtmlRenderer.render_morse_helper([[1, 2], [3], [1, 2]]),
"[morse: db0]": FiftyOhmHtmlRenderer.render_morse_helper([[2, 1, 1], [2, 1, 1, 1], [2, 2, 2, 2, 2]]),
}
for assertion in assertions:
+2 -2
View File
@@ -18,7 +18,7 @@ def test_paragraph_html():
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.",
"Niemals hätte ich gedacht, dass...ich ...nicht kann.": "Niemals hätte ich gedacht, dass...ich ...nicht kann.", # noqa: E501
"Oh nein ...ein Pinguin.": "Oh nein ...ein Pinguin.",
"Haha .. . Hahaha": "Haha .. . Hahaha",
}
@@ -55,7 +55,7 @@ def test_paragraph_latex():
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",
"Niemals hätte ich gedacht, dass...ich ...nicht kann.": "\nNiemals hätte ich gedacht, dass...ich~...nicht kann.\n", # noqa: E501
"Oh nein ...ein Pinguin.": "\nOh nein~...ein Pinguin.\n",
"Haha .. . Hahaha": "\nHaha .. . Hahaha\n",
}
+2 -2
View File
@@ -23,11 +23,11 @@ def test_qso_html():
for assertion in assertions:
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
@pytest.mark.slide
def test_qso_slide():
assertions = {
"<qso>\nfoo\n> bar\n</qso>":
'<div class="qso r-fit-text">\n<div class="qso_own fragment fade-right">foo</div>\n<div class="qso_other fragment fade-left">bar</div>\n</div>\n\n',
"<qso>\nfoo\n> bar\n</qso>": '<div class="qso r-fit-text">\n<div class="qso_own fragment fade-right">foo</div>\n<div class="qso_other fragment fade-left">bar</div>\n</div>\n\n', # noqa: E501
}
for assertion in assertions:
+4 -4
View File
@@ -46,10 +46,10 @@ def test_question_translation_html():
@pytest.mark.latex
def test_question_latex():
assertions = {
"[question:123]": "\question{123}",
"\n[question:123]\n": "\question{123}",
"\n[question:123]\n[question:123]": "\question{123}\question{123}",
"Foo\n[question:123]\nBar": "\nFoo\n\question{123}\nBar\n",
"[question:123]": r"\question{123}",
"\n[question:123]\n": r"\question{123}",
"\n[question:123]\n[question:123]": r"\question{123}\question{123}",
"Foo\n[question:123]\nBar": "\nFoo\n\\question{123}\nBar\n",
}
def test_function(input):
+5 -5
View File
@@ -24,11 +24,11 @@ def test_quote_html():
@pytest.mark.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",
'"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',
}
+2 -2
View File
@@ -10,9 +10,9 @@ def test_references_html():
# Right now this tests only the default values.
# The correct behavior can be tested when the information is added to the renderer class
assertions = {
"[ref:e_oszilloskop_bildschirmfoto_sinus]": '<a href="section.html#ref_e_oszilloskop_bildschirmfoto_sinus" onclick="highlightRef(\'e_oszilloskop_bildschirmfoto_sinus\');">0</a>',
"[ref:e_oszilloskop_bildschirmfoto_sinus]": '<a href="section.html#ref_e_oszilloskop_bildschirmfoto_sinus" onclick="highlightRef(\'e_oszilloskop_bildschirmfoto_sinus\');">0</a>', # noqa: E501
"[ref:n_rst_r]": '<a href="section.html#ref_n_rst_r" onclick="highlightRef(\'n_rst_r\');">0</a>',
"[ref:Uuuuuh]": '<a href="section.html#ref_Uuuuuh" onclick="highlightRef(\'Uuuuuh\');">0</a>', # Test the default parameters
"[ref:Uuuuuh]": '<a href="section.html#ref_Uuuuuh" onclick="highlightRef(\'Uuuuuh\');">0</a>', # Test the default parameters # noqa: E501
}
for key, value in assertions.items():
+7 -7
View File
@@ -11,14 +11,14 @@ def test_table_html():
"| l: a |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n</table>\n',
"| r: a |": '<table>\n<tr>\n<th style="text-align: right;">a</th>\n</tr>\n</table>\n',
"| c: a |": '<table>\n<tr>\n<th style="text-align: center;">a</th>\n</tr>\n</table>\n',
"| l: a |\n| b |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;">b</td>\n</tr>\n</table>\n',
"| l: a |\n| b |\n| c |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;">b</td>\n</tr>\n<tr>\n<td style="text-align: left;">c</td>\n</tr>\n</table>\n',
"| a |\n| b |\n| c |": "<table>\n<tr>\n<th>a</th>\n</tr>\n<tr>\n<td>b</td>\n</tr>\n<tr>\n<td>c</td>\n</tr>\n</table>\n",
"| l: a |\n| *b* |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;"><em>b</em></td>\n</tr>\n</table>\n',
"| l: a |\n| b |\n[table:n_ab:A und B]": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;">b</td>\n</tr>\n<caption>A und B</caption></table>\n',
"| l: a |\n| b |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;">b</td>\n</tr>\n</table>\n', # noqa: E501
"| l: a |\n| b |\n| c |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;">b</td>\n</tr>\n<tr>\n<td style="text-align: left;">c</td>\n</tr>\n</table>\n', # noqa: E501
"| a |\n| b |\n| c |": "<table>\n<tr>\n<th>a</th>\n</tr>\n<tr>\n<td>b</td>\n</tr>\n<tr>\n<td>c</td>\n</tr>\n</table>\n", # noqa: E501
"| l: a |\n| *b* |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;"><em>b</em></td>\n</tr>\n</table>\n', # noqa: E501
"| l: a |\n| b |\n[table:n_ab:A und B]": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;">b</td>\n</tr>\n<caption>A und B</caption></table>\n', # noqa: E501
"| l: *a* |": '<table>\n<tr>\n<th style="text-align: left;"><em>a</em></th>\n</tr>\n</table>\n',
"| l: a |\n| [morse:a] |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;"><span class="morse"><span class="morse_char">\n<span class="morse_char">\n▄</span>\n<span class="morse_char">\n▄▄▄</span>\n</span>\n</span></td>\n</tr>\n</table>\n',
"| l: abc | r: abc | X: abc |\n| 123 | 456 | 789 | \n | 987 | 654 | 321 | ": '<table>\n<tr>\n<th style="text-align: left;">abc</th>\n<th style="text-align: right;">abc</th>\n<th>abc</th>\n</tr>\n<tr>\n<td style="text-align: left;">123</td>\n<td style="text-align: right;">456</td>\n<td>789</td>\n</tr>\n<tr>\n<td style="text-align: left;">987</td>\n<td style="text-align: right;">654</td>\n<td>321</td>\n</tr>\n</table>\n',
"| l: a |\n| [morse:a] |": '<table>\n<tr>\n<th style="text-align: left;">a</th>\n</tr>\n<tr>\n<td style="text-align: left;"><span class="morse"><span class="morse_char">\n<span class="morse_char">\n▄</span>\n<span class="morse_char">\n▄▄▄</span>\n</span>\n</span></td>\n</tr>\n</table>\n', # noqa: E501
"| l: abc | r: abc | X: abc |\n| 123 | 456 | 789 | \n | 987 | 654 | 321 | ": '<table>\n<tr>\n<th style="text-align: left;">abc</th>\n<th style="text-align: right;">abc</th>\n<th>abc</th>\n</tr>\n<tr>\n<td style="text-align: left;">123</td>\n<td style="text-align: right;">456</td>\n<td>789</td>\n</tr>\n<tr>\n<td style="text-align: left;">987</td>\n<td style="text-align: right;">654</td>\n<td>321</td>\n</tr>\n</table>\n', # noqa: E501
}
with FiftyOhmHtmlRenderer() as renderer:
+14 -14
View File
@@ -76,17 +76,17 @@ def test_thematic_break_latex():
@pytest.mark.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}",
"<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>": "",
}
@@ -98,9 +98,9 @@ def test_tag_latex():
@pytest.mark.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:
+1 -1
View File
@@ -23,7 +23,7 @@ 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 *Text* </u>": "\n\\underline{ Text \\emph{Text} }\n",
}
for assertion in assertions: