This commit is contained in:
Kovid Goyal 2021-07-27 08:44:50 +05:30
parent 55aa9e11db
commit 17f3d2d581
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -224,12 +224,12 @@ def parse_option_spec(spec: Optional[str] = None) -> Tuple[OptionSpecSeq, Option
def prettify(text: str) -> str:
def identity(x: str) -> str:
return x
def sub(m: Match) -> str:
role, text = m.group(1, 2)
try:
return str(role_map[role](text))
except KeyError:
return str(text)
return role_map.get(role, identity)(text)
text = re.sub(r':([a-z]+):`([^`]+)`', sub, text)
return text