Loading md_to_docx_converter/src/to_docx/preprocessing.py +12 −1 Original line number Diff line number Diff line Loading @@ -177,6 +177,8 @@ def change_images_to_use_high_quality(soup: BeautifulSoup, src: str): """ for img in soup.find_all("img"): img_src = img.get("src") width = img.get("width") height = img.get("height") img_name, _ = os.path.splitext(img_src) img_name = img_name.split("/")[-1] img_size = None # Initialize the image size Loading Loading @@ -206,7 +208,16 @@ def change_images_to_use_high_quality(soup: BeautifulSoup, src: str): # img_src = img_src.replace(".png", ".jpg") img["src"] = img_src if img_size: if width and not height: img["width"] = width img["height"] = None elif height and not width: img["height"] = height img["width"] = None elif width and height: img["width"] = width img["height"] = height elif img_size: if img_size[0] is not None: img["width"] = img_size[0] if img_size[1] is not None: Loading Loading
md_to_docx_converter/src/to_docx/preprocessing.py +12 −1 Original line number Diff line number Diff line Loading @@ -177,6 +177,8 @@ def change_images_to_use_high_quality(soup: BeautifulSoup, src: str): """ for img in soup.find_all("img"): img_src = img.get("src") width = img.get("width") height = img.get("height") img_name, _ = os.path.splitext(img_src) img_name = img_name.split("/")[-1] img_size = None # Initialize the image size Loading Loading @@ -206,7 +208,16 @@ def change_images_to_use_high_quality(soup: BeautifulSoup, src: str): # img_src = img_src.replace(".png", ".jpg") img["src"] = img_src if img_size: if width and not height: img["width"] = width img["height"] = None elif height and not width: img["height"] = height img["width"] = None elif width and height: img["width"] = width img["height"] = height elif img_size: if img_size[0] is not None: img["width"] = img_size[0] if img_size[1] is not None: Loading