Merge pull request #7 from DARC-e-V/ci/check-format
CI: check format with ruff using GH actions
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
name: Ruff
|
||||||
|
on: pull_request
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
jobs:
|
||||||
|
ruff:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: astral-sh/ruff-action@v3
|
||||||
|
with:
|
||||||
|
args: check --output-format=github
|
||||||
|
- uses: astral-sh/ruff-action@v3
|
||||||
|
with:
|
||||||
|
args: format --diff
|
||||||
+8
-13
@@ -8,7 +8,7 @@ class DirectusAPI:
|
|||||||
self.base_url = base_url
|
self.base_url = base_url
|
||||||
self.access_token = access_token
|
self.access_token = access_token
|
||||||
|
|
||||||
def __get_raw(self, endpoint, params = None):
|
def __get_raw(self, endpoint, params=None):
|
||||||
if params is None:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
for k in params.keys():
|
for k in params.keys():
|
||||||
@@ -16,16 +16,11 @@ class DirectusAPI:
|
|||||||
params[k] = json.dumps(params[k])
|
params[k] = json.dumps(params[k])
|
||||||
url = self.base_url + endpoint
|
url = self.base_url + endpoint
|
||||||
result = requests.get(
|
result = requests.get(
|
||||||
url,
|
url, params=params, headers={"Authorization": f"Bearer {self.access_token}", "Cache-Control": "no-store"}
|
||||||
params = params,
|
|
||||||
headers = {
|
|
||||||
"Authorization": f"Bearer {self.access_token}",
|
|
||||||
"Cache-Control": "no-store"
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get(self, endpoint, params = None):
|
def get(self, endpoint, params=None):
|
||||||
if params is None:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
result = self.__get_raw(endpoint, params)
|
result = self.__get_raw(endpoint, params)
|
||||||
@@ -39,8 +34,8 @@ class DirectusAPI:
|
|||||||
print(f"Error: {e}")
|
print(f"Error: {e}")
|
||||||
return None
|
return None
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_one(self, endpoint, params = None):
|
def get_one(self, endpoint, params=None):
|
||||||
if params is None:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
results = self.get(endpoint, params)
|
results = self.get(endpoint, params)
|
||||||
@@ -50,12 +45,12 @@ class DirectusAPI:
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
raise Exception("One result expected, but got more than one result")
|
raise Exception("One result expected, but got more than one result")
|
||||||
|
|
||||||
def get_file(self, endpoint, params = None):
|
def get_file(self, endpoint, params=None):
|
||||||
if params is None:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
result = self.__get_raw(endpoint, params)
|
result = self.__get_raw(endpoint, params)
|
||||||
data = result.content
|
data = result.content
|
||||||
if data is None:
|
if data is None:
|
||||||
raise Exception("No data from API")
|
raise Exception("No data from API")
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ select = [
|
|||||||
# pycodestyle
|
# pycodestyle
|
||||||
# Ensure PEP8-compatible code style.
|
# Ensure PEP8-compatible code style.
|
||||||
"E",
|
"E",
|
||||||
|
"W",
|
||||||
# pep8-naming
|
# pep8-naming
|
||||||
# Ensure consisten, PEP8-compatible naming.
|
# Ensure consisten, PEP8-compatible naming.
|
||||||
"N",
|
"N",
|
||||||
@@ -38,6 +39,11 @@ select = [
|
|||||||
"C90",
|
"C90",
|
||||||
# ruff-specific: No unused noqa directives
|
# ruff-specific: No unused noqa directives
|
||||||
"RUF100",
|
"RUF100",
|
||||||
|
## Write modern python code
|
||||||
|
# Use f-strings instead of joining strings
|
||||||
|
"FLY",
|
||||||
|
# Check refurb rules
|
||||||
|
"FURB",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from mistletoe.block_token import BlockToken
|
from mistletoe.block_token import BlockToken
|
||||||
from mistletoe.span_token import SpanToken
|
|
||||||
|
|
||||||
|
|
||||||
class BlockComment(BlockToken):
|
class BlockComment(BlockToken):
|
||||||
|
|||||||
@@ -172,7 +172,10 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
|||||||
return f"{lookup[token.first]}{token.second}{lookup[token.third]}"
|
return f"{lookup[token.first]}{token.second}{lookup[token.third]}"
|
||||||
|
|
||||||
def render_references(self, token):
|
def render_references(self, token):
|
||||||
return f'<a href="{self.section_url}#ref_{token.first}" onclick="highlightRef(\'{token.first}\');">{self.ref_id}</a>'
|
return (
|
||||||
|
f'<a href="{self.section_url}#ref_{token.first}"'
|
||||||
|
f" onclick=\"highlightRef('{token.first}');\">{self.ref_id}</a>"
|
||||||
|
)
|
||||||
|
|
||||||
def render_question(self, token):
|
def render_question(self, token):
|
||||||
return self.question_renderer(token.question_number)
|
return self.question_renderer(token.question_number)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
|||||||
Question,
|
Question,
|
||||||
Picture,
|
Picture,
|
||||||
Photo,
|
Photo,
|
||||||
Table
|
Table,
|
||||||
)
|
)
|
||||||
self.question_renderer = question_renderer
|
self.question_renderer = question_renderer
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
|||||||
return rf"\{tagtype}{{{self.render_inner(token)}}}"
|
return rf"\{tagtype}{{{self.render_inner(token)}}}"
|
||||||
|
|
||||||
def render_halfwidth_spaces(self, token):
|
def render_halfwidth_spaces(self, token):
|
||||||
return f"{token.first}.\,{token.second}."
|
return rf"{token.first}.\,{token.second}."
|
||||||
|
|
||||||
def render_nonbreaking_spaces(self, token):
|
def render_nonbreaking_spaces(self, token):
|
||||||
return f"{token.first}~{token.second}"
|
return f"{token.first}~{token.second}"
|
||||||
@@ -105,7 +105,7 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
|||||||
\captionof{{figure}}{{{text}}}
|
\captionof{{figure}}{{{text}}}
|
||||||
\label{{{ref}}}"""
|
\label{{{ref}}}"""
|
||||||
|
|
||||||
def render_picture(self, token) :
|
def render_picture(self, token):
|
||||||
return self.render_picture_helper(token.id, token.ref, token.text, token.number)
|
return self.render_picture_helper(token.id, token.ref, token.text, token.number)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -114,26 +114,26 @@ class FiftyOhmLaTeXRenderer(LaTeXRenderer):
|
|||||||
\captionof{{figure}}{{{text}}}
|
\captionof{{figure}}{{{text}}}
|
||||||
\label{{{ref}}}"""
|
\label{{{ref}}}"""
|
||||||
|
|
||||||
def render_photo(self, token) :
|
def render_photo(self, token):
|
||||||
return self.render_photo_helper(token.id, token.ref, token.text, token.number)
|
return self.render_photo_helper(token.id, token.ref, token.text, token.number)
|
||||||
|
|
||||||
def render_table(self, token):
|
def render_table(self, token):
|
||||||
alignments = token.alignment
|
alignments = token.alignment
|
||||||
align = ""
|
align = ""
|
||||||
for alignment in alignments :
|
for alignment in alignments:
|
||||||
align += alignment
|
align += alignment
|
||||||
|
|
||||||
table = f"\\begin{{DARCtabular}}{{{align}}}\n"
|
table = f"\\begin{{DARCtabular}}{{{align}}}\n"
|
||||||
|
|
||||||
for row in token.children:
|
for row in token.children:
|
||||||
for j, cell in enumerate(row.children):
|
for j, cell in enumerate(row.children):
|
||||||
table += self.render_inner(cell)
|
table += self.render_inner(cell)
|
||||||
if j < len(row.children) - 1:
|
if j < len(row.children) - 1:
|
||||||
table += " & "
|
table += " & "
|
||||||
table += r"\\"+ "\n"
|
table += r"\\" + "\n"
|
||||||
|
|
||||||
table += "\\end{DARCtabular}"
|
table += "\\end{DARCtabular}"
|
||||||
if token.caption != "" :
|
if token.caption != "":
|
||||||
table += f"\\captionof{{figure}}{{{token.caption}}}\n"
|
table += f"\\captionof{{figure}}{{{token.caption}}}\n"
|
||||||
table += f"\\label{{{token.name}}}\n"
|
table += f"\\label{{{token.name}}}\n"
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -15,10 +15,10 @@ class Include(BlockToken):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def read(cls, lines):
|
def read(cls, lines):
|
||||||
re.compile(r'')
|
re.compile(r"")
|
||||||
line = next(lines) # Consume the line with the include directive
|
line = next(lines) # Consume the line with the include directive
|
||||||
ident = re.match(r"^\s*\[include:\s*([^\]]+)\]", line).group(1)
|
ident = re.match(r"^\s*\[include:\s*([^\]]+)\]", line).group(1)
|
||||||
return ident
|
return ident
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
self.ident = match
|
self.ident = match
|
||||||
|
|||||||
+1
-1
@@ -87,4 +87,4 @@ class Morse(SpanToken):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
pattern = re.compile(r'\[morse:\s*([^\]]+)\]')
|
pattern = re.compile(r"\[morse:\s*([^\]]+)\]")
|
||||||
|
|||||||
+1
-1
@@ -16,4 +16,4 @@ class Photo(SpanToken):
|
|||||||
self.id = match_object.group(1)
|
self.id = match_object.group(1)
|
||||||
self.ref = match_object.group(2)
|
self.ref = match_object.group(2)
|
||||||
self.text = match_object.group(3)
|
self.text = match_object.group(3)
|
||||||
self.number = "TODO"
|
self.number = "TODO"
|
||||||
|
|||||||
+1
-1
@@ -16,4 +16,4 @@ class Picture(SpanToken):
|
|||||||
self.id = match_object.group(1)
|
self.id = match_object.group(1)
|
||||||
self.ref = match_object.group(2)
|
self.ref = match_object.group(2)
|
||||||
self.text = match_object.group(3)
|
self.text = match_object.group(3)
|
||||||
self.number = "TODO"
|
self.number = "TODO"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Qso(BlockToken):
|
|||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
self.children = match
|
self.children = match
|
||||||
|
|
||||||
|
|
||||||
class QsoLine(BlockToken):
|
class QsoLine(BlockToken):
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_line(cls, line):
|
def parse_line(cls, line):
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def test_comment_latex():
|
|||||||
assertions = {
|
assertions = {
|
||||||
"%Comment\nBar": "% Comment\n\nBar\n",
|
"%Comment\nBar": "% Comment\n\nBar\n",
|
||||||
"%Comment\n": "% Comment\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",
|
"Foo\n%Comment\nBar": "\nFoo\n% Comment\n\nBar\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ def test_halfwidth_space_html():
|
|||||||
@pytest.mark.latex
|
@pytest.mark.latex
|
||||||
def test_halfwidth_space_latex():
|
def test_halfwidth_space_latex():
|
||||||
input = "Dies ist z.B. ein Test. D.h. hier sollten d.h. Spaces ersetzt worden sein."
|
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
|
assert mistletoe.markdown(input, FiftyOhmLaTeXRenderer) == target
|
||||||
|
|||||||
@@ -69,11 +69,13 @@ def question_stub(input):
|
|||||||
answer_pictures=answer_pictures,
|
answer_pictures=answer_pictures,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def include_stub(include):
|
def include_stub(include):
|
||||||
with open("data/includes.json") as file:
|
with open("data/includes.json") as file:
|
||||||
includes = json.load(file)
|
includes = json.load(file)
|
||||||
return includes.get(include)
|
return includes.get(include)
|
||||||
|
|
||||||
|
|
||||||
def test_html(capsys):
|
def test_html(capsys):
|
||||||
with capsys.disabled():
|
with capsys.disabled():
|
||||||
with open("test/acceptanceTest.md") as file:
|
with open("test/acceptanceTest.md") as file:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
|||||||
@pytest.mark.html
|
@pytest.mark.html
|
||||||
def test_include_html():
|
def test_include_html():
|
||||||
assertions = {
|
assertions = {
|
||||||
'[include:ident]': "ident\n",
|
"[include:ident]": "ident\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_function(input):
|
def test_function(input):
|
||||||
@@ -15,4 +15,4 @@ def test_include_html():
|
|||||||
|
|
||||||
with FiftyOhmHtmlRenderer(include_handler=test_function) as renderer:
|
with FiftyOhmHtmlRenderer(include_handler=test_function) as renderer:
|
||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
assert renderer.render(Document(assertion)) == assertions[assertion]
|
assert renderer.render(Document(assertion)) == assertions[assertion]
|
||||||
|
|||||||
+6
-6
@@ -8,12 +8,12 @@ from test.util import paragraph
|
|||||||
@pytest.mark.html
|
@pytest.mark.html
|
||||||
def test_morse_html():
|
def test_morse_html():
|
||||||
assertions = {
|
assertions = {
|
||||||
'[morse:a]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
|
"[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] 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: a]": FiftyOhmHtmlRenderer.render_morse_helper([[1, 2]]),
|
||||||
'[morse: aaa]': FiftyOhmHtmlRenderer.render_morse_helper([[1, 2], [1, 2], [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: 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: db0]": FiftyOhmHtmlRenderer.render_morse_helper([[2, 1, 1], [2, 1, 1, 1], [2, 2, 2, 2, 2]]),
|
||||||
}
|
}
|
||||||
|
|
||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def test_paragraph_html():
|
|||||||
def test_three_points_html():
|
def test_three_points_html():
|
||||||
assertions = {
|
assertions = {
|
||||||
"Heute hatte ich ... zum Mittagessen.": "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.",
|
"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.",
|
"Oh nein ...ein Pinguin.": "Oh nein ...ein Pinguin.",
|
||||||
"Haha .. . Hahaha": "Haha .. . Hahaha",
|
"Haha .. . Hahaha": "Haha .. . Hahaha",
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ def test_paragraph_latex():
|
|||||||
def test_three_points_latex():
|
def test_three_points_latex():
|
||||||
assertions = {
|
assertions = {
|
||||||
"Heute hatte ich ... zum Mittagessen.": "\nHeute hatte ich~...~zum Mittagessen.\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",
|
"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",
|
"Oh nein ...ein Pinguin.": "\nOh nein~...ein Pinguin.\n",
|
||||||
"Haha .. . Hahaha": "\nHaha .. . Hahaha\n",
|
"Haha .. . Hahaha": "\nHaha .. . Hahaha\n",
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -23,11 +23,11 @@ def test_qso_html():
|
|||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
|
assert mistletoe.markdown(assertion, FiftyOhmHtmlRenderer) == assertions[assertion]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slide
|
@pytest.mark.slide
|
||||||
def test_qso_slide():
|
def test_qso_slide():
|
||||||
assertions = {
|
assertions = {
|
||||||
"<qso>\nfoo\n> bar\n</qso>":
|
"<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
|
||||||
'<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',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ def test_question_html():
|
|||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
assert renderer.render(Document(assertion)) == assertions[assertion]
|
assert renderer.render(Document(assertion)) == assertions[assertion]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.html
|
@pytest.mark.html
|
||||||
def test_question_translation_html():
|
def test_question_translation_html():
|
||||||
assertions = {
|
assertions = {
|
||||||
@@ -34,7 +35,7 @@ def test_question_translation_html():
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_function(input):
|
def test_function(input):
|
||||||
with open('data/metadata.json') as file:
|
with open("data/metadata.json") as file:
|
||||||
metadata = json.load(file)
|
metadata = json.load(file)
|
||||||
return metadata[f"{input}"].get("number")
|
return metadata[f"{input}"].get("number")
|
||||||
|
|
||||||
@@ -46,14 +47,14 @@ def test_question_translation_html():
|
|||||||
@pytest.mark.latex
|
@pytest.mark.latex
|
||||||
def test_question_latex():
|
def test_question_latex():
|
||||||
assertions = {
|
assertions = {
|
||||||
"[question:123]": "\question{123}",
|
"[question:123]": r"\question{123}",
|
||||||
"\n[question:123]\n": "\question{123}",
|
"\n[question:123]\n": r"\question{123}",
|
||||||
"\n[question:123]\n[question:123]": "\question{123}\question{123}",
|
"\n[question:123]\n[question:123]": r"\question{123}\question{123}",
|
||||||
"Foo\n[question:123]\nBar": "\nFoo\n\question{123}\nBar\n",
|
"Foo\n[question:123]\nBar": "\nFoo\n\\question{123}\nBar\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_function(input):
|
def test_function(input):
|
||||||
return "\\question{"+input+"}"
|
return "\\question{" + input + "}"
|
||||||
|
|
||||||
with FiftyOhmLaTeXRenderer(test_function) as renderer:
|
with FiftyOhmLaTeXRenderer(test_function) as renderer:
|
||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
|
|||||||
+5
-5
@@ -24,11 +24,11 @@ def test_quote_html():
|
|||||||
@pytest.mark.latex
|
@pytest.mark.latex
|
||||||
def test_quote_latex():
|
def test_quote_latex():
|
||||||
assertions = {
|
assertions = {
|
||||||
'"quote"': "\n\enquote{quote}\n",
|
'"quote"': "\n\\enquote{quote}\n",
|
||||||
'" quote "': "\n\enquote{ quote }\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 te1} filltext \\enquote{qu ot e2}\n",
|
||||||
'"quo *te1*" filltext "qu ot e2"': "\n\enquote{quo \emph{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',
|
'""': '\n""\n',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ def test_references_html():
|
|||||||
# Right now this tests only the default values.
|
# Right now this tests only the default values.
|
||||||
# The correct behavior can be tested when the information is added to the renderer class
|
# The correct behavior can be tested when the information is added to the renderer class
|
||||||
assertions = {
|
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: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():
|
for key, value in assertions.items():
|
||||||
|
|||||||
+7
-7
@@ -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',
|
"| 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',
|
"| 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',
|
"| 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 |": '<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',
|
"| 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",
|
"| 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',
|
"| 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',
|
"| 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* |": '<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: 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',
|
"| 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:
|
with FiftyOhmHtmlRenderer() as renderer:
|
||||||
|
|||||||
+14
-14
@@ -76,17 +76,17 @@ def test_thematic_break_latex():
|
|||||||
@pytest.mark.latex
|
@pytest.mark.latex
|
||||||
def test_tag_latex():
|
def test_tag_latex():
|
||||||
assertions = {
|
assertions = {
|
||||||
"<margin>\nFoo\n</margin>": "\Margin{\nFoo\n}",
|
"<margin>\nFoo\n</margin>": "\\Margin{\nFoo\n}",
|
||||||
"<danger>\nFoo\n</danger>": "\MarginDanger{\nFoo\n}",
|
"<danger>\nFoo\n</danger>": "\\MarginDanger{\nFoo\n}",
|
||||||
"<warning>\nFoo\n</warning>": "\MarginWarning{\nFoo\n}",
|
"<warning>\nFoo\n</warning>": "\\MarginWarning{\nFoo\n}",
|
||||||
"<attention>\nFoo\n</attention>": "\MarginAttention{\nFoo\n}",
|
"<attention>\nFoo\n</attention>": "\\MarginAttention{\nFoo\n}",
|
||||||
"<tip>\nFoo\n</tip>": "\MarginTip{\nFoo\n}",
|
"<tip>\nFoo\n</tip>": "\\MarginTip{\nFoo\n}",
|
||||||
"<webtip>\nFoo\n</webtip>": "\WebTip{\nFoo\n}",
|
"<webtip>\nFoo\n</webtip>": "\\WebTip{\nFoo\n}",
|
||||||
"<unit>\nFoo\n</unit>": "\MarginUnit{\nFoo\n}",
|
"<unit>\nFoo\n</unit>": "\\MarginUnit{\nFoo\n}",
|
||||||
"<indepth>\nFoo\n</indepth>": "\MarginInDepth{\nFoo\n}",
|
"<indepth>\nFoo\n</indepth>": "\\MarginInDepth{\nFoo\n}",
|
||||||
"<webindepth>\nFoo\n</webindepth>": "\MarginWebInDepth{\nFoo\n}",
|
"<webindepth>\nFoo\n</webindepth>": "\\MarginWebInDepth{\nFoo\n}",
|
||||||
"<webmargin>\nFoo\n</webmargin>": "\WebMargin{\nFoo\n}",
|
"<webmargin>\nFoo\n</webmargin>": "\\WebMargin{\nFoo\n}",
|
||||||
"<fullwidth>\nFoo\n</fullwidth>": "\FullWidth{\nFoo\n}",
|
"<fullwidth>\nFoo\n</fullwidth>": "\\FullWidth{\nFoo\n}",
|
||||||
"<latexonly>\nFoo\n</latexonly>": "\nFoo\n",
|
"<latexonly>\nFoo\n</latexonly>": "\nFoo\n",
|
||||||
"<webonly>\nFoo\n</webonly>": "",
|
"<webonly>\nFoo\n</webonly>": "",
|
||||||
}
|
}
|
||||||
@@ -98,9 +98,9 @@ def test_tag_latex():
|
|||||||
@pytest.mark.latex
|
@pytest.mark.latex
|
||||||
def test_thematic_break_and_tag_latex():
|
def test_thematic_break_and_tag_latex():
|
||||||
assertions = {
|
assertions = {
|
||||||
"---\n<margin>\nFoo\n</margin>": "\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<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>\n---\n<margin>\nFoo\n</margin>": "\\Margin{\nFoo\n}\\Margin{\nFoo\n}",
|
||||||
}
|
}
|
||||||
|
|
||||||
for assertion in assertions:
|
for assertion in assertions:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def test_underline_latex():
|
|||||||
assertions = {
|
assertions = {
|
||||||
"<u>Text</u>": "\n\\underline{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 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:
|
for assertion in assertions:
|
||||||
|
|||||||
Reference in New Issue
Block a user