diff --git a/pptx2md/outputter.py b/pptx2md/outputter.py index 3beadd6..2ab46e5 100644 --- a/pptx2md/outputter.py +++ b/pptx2md/outputter.py @@ -361,31 +361,18 @@ def put_elements(elements: List[SlideElement]): self.put_para(":::") if slide_idx < len(presentation_data.slides) - 1 and self.config.enable_slides: - self.put_para("\n---\n") + self.put_para("\n***\n") self.close() def put_header(self): - self.ofile.write('''--- -title: "Presentation Title" -author: "Author" -format: - revealjs: - slide-number: c/t - width: 1600 - height: 900 - logo: img/logo.png - footer: "Organization" - incremental: true - theme: [simple] ---- -''') + pass def put_title(self, text, level): - self.ofile.write('#' * level + ' ' + text + '\n\n') + self.ofile.write('\n\n' + '#' * level + ' ' + text + '\n\n') def put_list(self, text, level): - self.ofile.write(' ' * level + '* ' + text.strip() + '\n') + self.ofile.write(' ' * level + '- ' + text.strip() + '\n') def put_para(self, text): self.ofile.write(text + '\n\n') @@ -403,13 +390,13 @@ def put_table(self, table): self.ofile.write('\n'.join([gen_table_row(row) for row in table[1:]]) + '\n\n') def get_accent(self, text): - return ' _' + text + '_ ' + return ' *' + text + '* ' def get_strong(self, text): return ' __' + text + '__ ' def get_colored(self, text, rgb): - return ' %s ' % (rgb_to_hex(rgb), text) + return ' [%s]{style="color:%s"} ' % (text, rgb_to_hex(rgb)) def get_hyperlink(self, text, url): return '[' + text + '](' + url + ')' diff --git a/pptx2md/parser.py b/pptx2md/parser.py index edcc10a..d1a90d9 100644 --- a/pptx2md/parser.py +++ b/pptx2md/parser.py @@ -44,8 +44,6 @@ logger = logging.getLogger(__name__) -picture_count = 0 - def is_title(shape): if shape.is_placeholder and (shape.placeholder_format.type == PP_PLACEHOLDER.TITLE or @@ -148,11 +146,11 @@ def process_picture(config: ConversionConfig, shape, slide_idx) -> Union[ImageEl if config.disable_image: return None - global picture_count - - file_prefix = ''.join(os.path.basename(config.pptx_path).split('.')[:-1]) - pic_name = file_prefix + f'_{picture_count}' - pic_ext = shape.image.ext + pic_name = shape.image.sha1 + if shape.image.filename: + pic_ext = shape.image.filename.split('.')[-1] + else: + pic_ext = shape.image.ext if not os.path.exists(config.image_dir): os.makedirs(config.image_dir) @@ -161,10 +159,9 @@ def process_picture(config: ConversionConfig, shape, slide_idx) -> Union[ImageEl img_outputter_path = os.path.relpath(output_path, common_path) with open(output_path, 'wb') as f: f.write(shape.image.blob) - picture_count += 1 # normal images - if pic_ext != 'wmf': + if config.disable_wmf or (pic_ext != 'wmf' and pic_ext != 'emf'): return ImageElement(path=img_outputter_path, width=config.image_width) # wmf images, try to convert, if failed, output as original