Browse Source

fixed img path

Bachir Soussi Chiadmi 7 years ago
parent
commit
b7cc198f32
1 changed files with 14 additions and 6 deletions
  1. 14 6
      bin/build.py

+ 14 - 6
bin/build.py

@@ -124,15 +124,16 @@ def generate_html(book, toc):
                               #  outputfile=out_f)
       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
       for img in output_dom.find_all('img'):
+         # print('-- img ',img)
          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)
          # print('- -  '+src_img)
 
@@ -149,6 +150,13 @@ def generate_html(book, toc):
 
          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
 
    # create main html file from filled template html dom