Skip to content

Commit 8237620

Browse files
committed
Fix auto html
1 parent 24f5307 commit 8237620

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

_auto_html.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,23 @@
208208
"Wbr",
209209
]
210210

211+
inline_html_classes = [
212+
"Area",
213+
"Base",
214+
"Br",
215+
"Col",
216+
"Embed",
217+
"Hr",
218+
"Img",
219+
"Input",
220+
"Link",
221+
"Meta",
222+
"Param",
223+
"Source",
224+
"Track",
225+
"Wbr",
226+
]
227+
211228
html_map = {key: html_map.get(key, "HTMLElementProps") for key in html_classes}
212229

213230
template = """from typing import TYPE_CHECKING, Unpack
@@ -221,9 +238,10 @@ class {class_name}(Element):
221238
def __init__(self, *children: "ChildType", **kwargs: Unpack["{props_class_name}"]):
222239
super().__init__(*children, **kwargs)
223240
224-
tag_name = "{class_name_lower}"
241+
tag_name = "{class_name_lower}"{inline}
225242
"""
226243

244+
inline_string = "\n inline = True"
227245

228246
lower_keys = {key.lower(): key for key in html_map}
229247

@@ -232,6 +250,7 @@ def __init__(self, *children: "ChildType", **kwargs: Unpack["{props_class_name}"
232250
class_name_lower = class_name.lower()
233251
props_class_name = props
234252
filename = f"{class_name_lower}.py"
253+
inline = inline_string if class_name in inline_html_classes else ""
235254

236255
if class_name == "Meta":
237256
continue
@@ -240,6 +259,6 @@ def __init__(self, *children: "ChildType", **kwargs: Unpack["{props_class_name}"
240259
filename = "del_.py"
241260

242261
with open(HTML_FILES / filename, "w") as f:
243-
f.write(template.format(class_name=class_name, class_name_lower=class_name_lower, props_class_name=props_class_name))
262+
f.write(template.format(class_name=class_name, class_name_lower=class_name_lower, props_class_name=props_class_name, inline=inline))
244263

245264

0 commit comments

Comments
 (0)