Explicitly set force_sep on writing_rootdir for relative links.

master
Ethan Dalool 2020-11-01 00:21:39 -07:00
parent 05e6470442
commit a7959e0b0f
1 changed files with 3 additions and 2 deletions

View File

@ -157,6 +157,7 @@ def soup_adjust_relative_links(soup, md_file, repo_path):
relative links into absolute links starting from /writing. relative links into absolute links starting from /writing.
''' '''
folder = pathclass.Path(md_file.parent, force_sep='/') folder = pathclass.Path(md_file.parent, force_sep='/')
writing_rootdir = pathclass.Path(WRITING_ROOTDIR, force_sep='/')
def fixby(tagname, attribute): def fixby(tagname, attribute):
links = soup.find_all(tagname) links = soup.find_all(tagname)
for link in links: for link in links:
@ -168,9 +169,9 @@ def soup_adjust_relative_links(soup, md_file, repo_path):
if href.startswith('#'): if href.startswith('#'):
continue continue
href = folder.join(href) href = folder.join(href)
href = '/' + href.relative_to(WRITING_ROOTDIR.parent, simple=True) href = '/' + href.relative_to(writing_rootdir.parent, simple=True)
if not href.startswith('/writing/'): if not href.startswith('/writing/'):
raise ValueError('Somethings wrong') raise ValueError('Somethings wrong with', href)
link[attribute] = href link[attribute] = href
fixby('a', 'href') fixby('a', 'href')
fixby('img', 'src') fixby('img', 'src')