This commit is contained in:
Kovid Goyal 2022-08-24 15:02:36 +05:30
parent b32ee5ee46
commit d595084395
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -93,20 +93,21 @@ def remove_markup(text: str) -> str:
return t, q
def sub(m: 'Match[str]') -> str:
if m.group(1) in ('ref', 'iss', 'pull', 'disc'):
key = m.group(1)
if key in ('ref', 'iss', 'pull', 'disc'):
t, q = extract(m)
q = imap.get(m.group(1), '') + q
q = imap.get(key, '') + q
url = resolve_ref(q)
if not url:
raise KeyError(f'Failed to resolve :{m.group(1)}: {q}')
return f'{t} <{url}>'
if m.group(1) == 'doc':
if key == 'doc':
t, q = extract(m)
return f'{t} <{website_url(q)}>'
if m.group(1) in ('term', 'option'):
if key in ('term', 'option'):
t, _ = extract(m)
return t
if m.group(1) in ('ac', 'opt'):
if key in ('ac', 'opt'):
t, q = extract(m)
return f'{t} {q}' if q and q != t else t