mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Another fix to auto-relinker
This commit is contained in:
parent
fab769e0d0
commit
f2d460672e
1 changed files with 26 additions and 18 deletions
|
|
@ -46,31 +46,39 @@ def create_toctree():
|
|||
def _sub(match):
|
||||
grpdict = match.groupdict()
|
||||
txt, url = grpdict['txt'], grpdict['url']
|
||||
fname, *part = url.rsplit("/", 1)
|
||||
fname = part[0] if part else fname
|
||||
fname = fname.rsplit(".", 1)[0]
|
||||
fname, *anchor = url.rsplit("#", 1)
|
||||
if fname in docref_map:
|
||||
urlout = docref_map[fname] + ('#' + anchor[0] if anchor else '')
|
||||
if urlout != url:
|
||||
print(f" Remapped link [{txt}]({url}) -> [{txt}]({urlout})")
|
||||
else:
|
||||
|
||||
if "http" in url and "://" in url:
|
||||
urlout = url
|
||||
else:
|
||||
fname, *part = url.rsplit("/", 1)
|
||||
fname = part[0] if part else fname
|
||||
fname = fname.rsplit(".", 1)[0]
|
||||
fname, *anchor = fname.rsplit("#", 1)
|
||||
if fname in docref_map:
|
||||
urlout = docref_map[fname] + ('#' + anchor[0] if anchor else '')
|
||||
if urlout != url:
|
||||
print(f" Remapped link [{txt}]({url}) -> [{txt}]({urlout})")
|
||||
else:
|
||||
urlout = url
|
||||
return f"[{txt}]({urlout})"
|
||||
|
||||
def _sub_doc(match):
|
||||
grpdict = match.groupdict()
|
||||
txt, url = grpdict['txt'], grpdict['url']
|
||||
fname, *part = url.rsplit("/", 1)
|
||||
fname = part[0] if part else fname
|
||||
fname = fname.rsplit(".", 1)[0]
|
||||
fname, *anchor = url.rsplit("#", 1)
|
||||
if fname in docref_map:
|
||||
urlout = docref_map[fname] + ('#' + anchor[0] if anchor else '')
|
||||
if urlout != url:
|
||||
print(f" Remapped link [{txt}]: {url} -> [{txt}]: {urlout}")
|
||||
else:
|
||||
|
||||
if "http" in url and "://" in url:
|
||||
urlout = url
|
||||
else:
|
||||
fname, *part = url.rsplit("/", 1)
|
||||
fname = part[0] if part else fname
|
||||
fname = fname.rsplit(".", 1)[0]
|
||||
fname, *anchor = fname.rsplit("#", 1)
|
||||
if fname in docref_map:
|
||||
urlout = docref_map[fname] + ('#' + anchor[0] if anchor else '')
|
||||
if urlout != url:
|
||||
print(f" Remapped link [{txt}]: {url} -> [{txt}]: {urlout}")
|
||||
else:
|
||||
urlout = url
|
||||
return f"[{txt}]: {urlout}"
|
||||
|
||||
# replace / correct links in all files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue