mirror of
https://github.com/rendercv/rendercv.git
synced 2026-05-19 06:06:04 -04:00
Don't fail on empty links
This commit is contained in:
@@ -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 = (
|
||||
|
||||
Reference in New Issue
Block a user