Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions pptx2md/outputter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 ' <span style="color:%s">%s</span> ' % (rgb_to_hex(rgb), text)
return ' [%s]{style="color:%s"} ' % (text, rgb_to_hex(rgb))

def get_hyperlink(self, text, url):
return '[' + text + '](' + url + ')'
Expand Down
15 changes: 6 additions & 9 deletions pptx2md/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down