Don't fail on empty links

This commit is contained in:
Sina Atalay
2026-03-02 18:52:59 +03:00
parent 984e7b95da
commit 2e329bd45a

View File

@@ -5,8 +5,6 @@ from xml.etree.ElementTree import Element
import markdown
import markdown.core
from rendercv.exception import RenderCVUserError
def to_typst_string(elem: Element) -> str:
"""Recursively convert XML Element tree to Typst markup string.
@@ -48,14 +46,9 @@ def to_typst_string(elem: Element) -> str:
case "a":
# Link: [text](url) -> #link("url")[text]
href = child.get("href", "")
href = child.get("href") if child.get("href") else "https://example.com"
inner = to_typst_string(child)
child_content = f'#link("{href}")[{inner}]'
if not href:
message = (
f"Link url is not provided for [{inner}](url) in the YAML file!"
)
raise RenderCVUserError(message)
case "div":
child_content = (