fixed img path
This commit is contained in:
+14
-6
@@ -124,15 +124,16 @@ def generate_html(book, toc):
|
|||||||
# outputfile=out_f)
|
# outputfile=out_f)
|
||||||
output_dom = BeautifulSoup(output, 'html.parser')
|
output_dom = BeautifulSoup(output, 'html.parser')
|
||||||
|
|
||||||
|
|
||||||
# append html story page to template_dom
|
|
||||||
story_page = BeautifulSoup('<div class="story-page" id="story-page-'+str(pi)+'"></div>', 'html.parser')
|
|
||||||
story_page.div.append(output_dom)
|
|
||||||
story_dom.append(story_page)
|
|
||||||
|
|
||||||
# copy images
|
# copy images
|
||||||
for img in output_dom.find_all('img'):
|
for img in output_dom.find_all('img'):
|
||||||
|
# print('-- img ',img)
|
||||||
att_src = re.sub(r"^\/", "", img['src'])
|
att_src = re.sub(r"^\/", "", img['src'])
|
||||||
|
img['src'] = att_src
|
||||||
|
# domimg = output_dom.find('img', {'src':img['src']})
|
||||||
|
# domimg['src'] = att_src
|
||||||
|
# print(domimg)
|
||||||
|
|
||||||
|
|
||||||
src_img = os.path.join(_BOOK_SRC, att_src)
|
src_img = os.path.join(_BOOK_SRC, att_src)
|
||||||
# print('- - '+src_img)
|
# print('- - '+src_img)
|
||||||
|
|
||||||
@@ -149,6 +150,13 @@ def generate_html(book, toc):
|
|||||||
|
|
||||||
shutil.copyfile(src_img, dest_img)
|
shutil.copyfile(src_img, dest_img)
|
||||||
|
|
||||||
|
|
||||||
|
# append html story page to template_dom
|
||||||
|
story_page = BeautifulSoup('<div class="story-page" id="story-page-'+str(pi)+'"></div>', 'html.parser')
|
||||||
|
story_page.div.append(output_dom)
|
||||||
|
story_dom.append(story_page)
|
||||||
|
|
||||||
|
|
||||||
pi = pi+1
|
pi = pi+1
|
||||||
|
|
||||||
# create main html file from filled template html dom
|
# create main html file from filled template html dom
|
||||||
|
|||||||
Reference in New Issue
Block a user