fixed the header / structural elements export syntax

This commit is contained in:
Maximilien Rigaut 2022-06-15 22:25:36 +02:00
parent e3f41eee43
commit 77475d3414
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
3 changed files with 17 additions and 11 deletions

View File

@ -335,7 +335,7 @@ class SeContainer(BaseContainer):
type = "structural_elements"
def export(self, exm):
self.subtype = self[0].content[0]
self.subtype = "se_"+self[0].content[0]
return super().export(exm)

View File

@ -1,8 +1,11 @@
structural_elements:
div: ["<div{optionals}>", "</div>"]
article: ["<article{optionals}>", "</article>"]
aside: ["<aside{optionals}>", "</aside>"]
section: ["<section{optionals}>", "</section>"]
se_div: ["<div{optionals}>", "</div>"]
se_article: ["<article{optionals}>", "</article>"]
se_aside: ["<aside{optionals}>", "</aside>"]
se_section: ["<section{optionals}>", "</section>"]
se_nav: ["<nav{optionals}>", "</nav>"]
se_header: ["<header{optionals}>", "</header>"]
se_body: ["<body{optionals}>", "</body>"]
header: ["<h{header_level}{optionals}>", "</h{header_level}>"]
display: ["<p class=\"display-{display_level}\"{optionals}>", "</p>"]

View File

@ -12,12 +12,14 @@ __templates = config.ConfigLoader(pathresolver.b_path("templates/"))
__XF = pytest.mark.xfail
_all_templates = {
"structural_elements": [
["div", __GLk(1)],
["article", __GLk(1)],
["aside", __GLk(1)],
["section", __GLk(1)],
["se_div", __GLk(1)],
["se_article", __GLk(1)],
["se_aside", __GLk(1)],
["se_section", __GLk(1)],
["header", __GLk(1)],
["display", __GLk(1)],
["se_body", __GLk(1)],
["se_nav", __GLk(1)],
],
"inline_elements": [
["link", __GLk(1)],
@ -86,7 +88,7 @@ def test_export_response():
("table", "t_head"),
("table", "t_row"),
("table", "t_cell"),
("structural_elements", "div"),
("structural_elements", "se_div"),
])
def test_transform(export_type, export_subtype):
"""
@ -118,7 +120,7 @@ def test_get_template_error():
def test_with_optionnals():
em = export.ExportManager(__config, __templates)
em(export.ExportRequest("structural_elements", "div", _opts)) # noqa E741
em(export.ExportRequest("structural_elements", "se_div", _opts)) # noqa E741
def test_format_optionnals():
@ -147,6 +149,7 @@ def test_bad_header():
@pytest.mark.parametrize("export_type, export_subtype, line", zipped_templates)
def test_get_templates(export_type, export_subtype, line):
print(line)
em = export.ExportManager(__config, __templates)
# assert type(em.get_templates()) is dict
print(export_type, export_subtype)