mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-10-05 18:47:27 +03:00
DRYer
This commit is contained in:
parent
55aa9e11db
commit
17f3d2d581
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user