Handle close link tag

This commit is contained in:
object-Object 2023-10-09 20:35:00 -04:00
parent e91236a2bd
commit a92a4716a5

View file

@ -207,6 +207,11 @@ class Style(ABC, HexdocModel, frozen=True):
# close functions
if style_str.startswith("/"):
# links
if style_str[1:] == SpecialStyleType.link.value:
return _CloseTag(type=SpecialStyleType.link)
# all the other functions
if style_type := FunctionStyleType.get(style_str[1:]):
return _CloseTag(type=style_type)
@ -319,7 +324,11 @@ class LinkStyle(Style, frozen=True):
# intentionally not inheriting from Style, because this is basically an implementation
# detail of the parser and should not be returned or exposed anywhere
class _CloseTag(HexdocModel, frozen=True):
type: FunctionStyleType | Literal[SpecialStyleType.base, SpecialStyleType.color]
type: FunctionStyleType | Literal[
SpecialStyleType.link,
SpecialStyleType.base,
SpecialStyleType.color,
]
_FORMAT_RE = re.compile(r"\$\(([^)]*)\)")