diff --git a/pyproject.toml b/pyproject.toml
index c60fc65..d472fae 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "python-hiccup"
-version = "0.1.0"
+version = "0.2.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
diff --git a/src/python_hiccup/html/core.py b/src/python_hiccup/html/core.py
index b545602..b58dc26 100644
--- a/src/python_hiccup/html/core.py
+++ b/src/python_hiccup/html/core.py
@@ -43,6 +43,12 @@ def _to_bool_attributes(acc: str, attributes: set) -> str:
return _join(acc, attrs)
+def _closing_tag(element: str) -> bool:
+ specials = {"script"}
+
+ return str.lower(element) in specials
+
+
def _suffix(element_data: str) -> str:
specials = {"doctype"}
normalized = str.lower(element_data)
@@ -68,6 +74,9 @@ def _to_html(tag: Mapping) -> list:
if flattened or content:
return [f"<{begin}>", *flattened, *content, f"{element}>"]
+ if _closing_tag(element):
+ return [f"<{begin}>", f"{element}>"]
+
extra = _suffix(begin)
return [f"<{begin}{extra}>"]
diff --git a/test/test_render_html.py b/test/test_render_html.py
index 97c45be..a172e10 100644
--- a/test/test_render_html.py
+++ b/test/test_render_html.py
@@ -41,11 +41,20 @@ def test_parses_attribute_shorthand() -> None:
assert render(data) == expected
+def test_explicit_closing_tag() -> None:
+ """Assert that some html elements are parsed with a closing tag."""
+ data = ["script"]
+
+ expected = ""
+
+ assert render(data) == expected
+
+
def test_parses_boolean_attributes() -> None:
"""Assert that attributes without values, such as async or defer, is parsed as expected."""
data = ["script", {"async"}, {"src": "path/to/script"}]
- expected = ''
+ expected = ''
assert render(data) == expected
diff --git a/uv.lock b/uv.lock
index a6774c1..ac3b866 100644
--- a/uv.lock
+++ b/uv.lock
@@ -103,7 +103,7 @@ wheels = [
[[package]]
name = "python-hiccup"
-version = "0.1.0"
+version = "0.2.0"
source = { editable = "." }
[package.dev-dependencies]