#https://huggingface.co/spaces/MisterAI/GenDoc_05 #/home/user/python_pptx/python_pptx.py_01 from pptx import Presentation from pptx.util import Inches, Pt class PresentationGenerator: def __init__(self): pass def parse_presentation_content(self, content): slides = [] current_slide = None for line in content.split('\n'): line = line.strip() if line.startswith('TITRE:'): slides.append({'type': 'title', 'title': line[6:].strip()}) elif line.startswith('DIAPO'): if current_slide: slides.append(current_slide) current_slide = {'type': 'content', 'title': '', 'points': []} elif line.startswith('Titre:') and current_slide: current_slide['title'] = line[6:].strip() elif line.startswith('- ') and current_slide: current_slide['points'].append(line[2:].strip()) if current_slide: slides.append(current_slide) return slides def create_presentation(self, slides): prs = Presentation() title_slide = prs.slides.add_slide(prs.slide_layouts[0]) title_slide.shapes.title.text = slides[0]['title'] for slide in slides[1:]: content_slide = prs.slides.add_slide(prs.slide_layouts[1]) content_slide.shapes.title.text = slide['title'] if slide['points']: body = content_slide.shapes.placeholders[1].text_frame body.clear() for point in slide['points']: p = body.add_paragraph() p.text = point p.level = 0 return prs