slidedeckai.helpers.pptx_helper#
A set of functions to create a PowerPoint slide deck.
Add a list of texts as bullet points to a text frame and apply formatting. |
|
Apply bold and italic formatting while preserving the original word order without duplication. |
|
Create and save a PowerPoint presentation from parsed JSON content. |
|
Flatten a (hierarchical) list of bullet points to a single list containing each item and |
|
Return the index and name (lower case) of all placeholders present in a slide, except the title placeholder. |
|
Print all slide layouts and their placeholder indices/names. |
|
Remove the slide number from a given slide header. |
A set of functions to create a PowerPoint slide deck.
- slidedeckai.helpers.pptx_helper.add_bulleted_items(text_frame: TextFrame, flat_items_list: list)[source]#
Add a list of texts as bullet points to a text frame and apply formatting.
- Parameters:
text_frame (pptx.text.text.TextFrame) – The text frame where text is to be displayed.
flat_items_list (list) – The list of items to be displayed.
- slidedeckai.helpers.pptx_helper.format_text(frame_paragraph, text: str)[source]#
Apply bold and italic formatting while preserving the original word order without duplication.
- Parameters:
frame_paragraph – The paragraph to format.
text – The text to format with markdown-style formatting.
- slidedeckai.helpers.pptx_helper.generate_powerpoint_presentation(parsed_data: dict, slides_template: str, output_file_path: Path) list[source]#
Create and save a PowerPoint presentation from parsed JSON content.
- Parameters:
parsed_data (dict) – The presentation content as parsed JSON data.
slides_template (str) – The PPTX template key to use from GlobalConfig.
output_file_path (pathlib.Path) – Destination path for the generated PPTX file.
- Returns:
A list containing the presentation title and slide headers.
- slidedeckai.helpers.pptx_helper.get_flat_list_of_contents(items: list, level: int) list[tuple][source]#
- Flatten a (hierarchical) list of bullet points to a single list containing each item and
its level.
- Parameters:
items – A bullet point (string or list).
level – The current level of hierarchy.
- Returns:
A list of (bullet item text, hierarchical level) tuples.
- slidedeckai.helpers.pptx_helper.get_slide_placeholders(slide: Slide, layout_number: int, is_debug: bool = False) list[tuple[int, str]][source]#
Return the index and name (lower case) of all placeholders present in a slide, except the title placeholder.
A placeholder in a slide is a place to add content. Each placeholder has a name and an index. This index is not a list index; it is a key used to look up a dict and may be non-contiguous. The title placeholder always has index 0. User-added placeholders get indices starting from 10.
With user-edited or added placeholders, indices may be difficult to track. This function returns the placeholders’ names as well, which may help distinguish between placeholders.
- Parameters:
slide – The slide.
layout_number – The layout number used by the slide.
is_debug – Whether to print debugging statements.
- Returns:
A list of (index, name) tuples for placeholders present in the slide, excluding the title placeholder.
- Return type:
list[tuple[int, str]]