Skip to content

Commit

Permalink
Add support for pptx output file generation
Browse files Browse the repository at this point in the history
This commit adds a task to the mai playbook to use marp tool with the --pptx
option to generate PowerPoint compatible files.
  • Loading branch information
rascasoft committed Apr 18, 2024
1 parent db02315 commit 6e5b0ff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pandoc_agenda_output_pdf: "{{ kpa_project_dir }}/slides.agenda.pdf"
# Marp Markdown output files destination
marp_output_markdown: "{{ kpa_project_dir }}/slides.md"
marp_output_pdf: "{{ kpa_project_dir }}/slides.pdf"
# Set marp_output_pptx to generate a PowerPoint compatible file
# marp_output_pptx: "{{ kpa_project_dir }}/slides.pptx"

# Marp theme (default, gaia, uncover or a custom theme)
marp_theme: default
Expand Down Expand Up @@ -95,6 +97,10 @@ kpa_slides:
content: "{{ kpa_project_dir }}/contents/knowledge-pod-2.md"
```
For example, to generate a `pptx` output file just set the `marp_output_pptx`
variable, and the playbook will also run marp with the option to generate a
Microsoft PowerPoint compatible file.

Example Playbook
----------------

Expand All @@ -117,7 +123,7 @@ And execute it using `ansible-playbook`:

```console
> ansible-playbook tests/kpa_generator.yml
PLAY [Use a KPA Project to create Marp & Pandoc markdown fils and their pdf] ***
PLAY [Use a KPA Project to create Marp & Pandoc markdown and slide decks] ******
TASK [../.. : Create Marp slides markdown] *************************************
changed: [localhost]
Expand All @@ -128,11 +134,14 @@ changed: [localhost]
TASK [../.. : Generate pdf slides with Marp] ***********************************
changed: [localhost]
TASK [../.. : Generate pptx slides with Marp] **********************************
skipping: [localhost]
TASK [../.. : Generate pdf agenda with Pandoc] *********************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=4 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
localhost : ok=4 changed=4 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
```

This will generate two couples of files:
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pandoc_agenda_output_pdf: "{{ kpa_project_dir }}/slides.agenda.pdf"
# Marp Markdown output file destination
marp_output_markdown: "{{ kpa_project_dir }}/slides.md"
marp_output_pdf: "{{ kpa_project_dir }}/slides.pdf"
# Set marp_output_pptx to generate a PowerPoint compatible file
# marp_output_pptx: "{{ kpa_project_dir }}/slides.pptx"

# Marp theme (default, gaia, uncover or a custom theme)
marp_theme: default
Expand Down
17 changes: 15 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@
{{ marp_output_markdown }}
when:
- marp_output_pdf is defined
register: marp_cmd
changed_when: marp_cmd.rc == 0
register: marp_pdf_cmd
changed_when: marp_pdf_cmd.rc == 0

- name: Generate pptx slides with Marp
ansible.builtin.shell: |
marp --pptx \
--allow-local-files \
--html \
{% if marp_theme_file is defined %}--theme {{ marp_theme_file }}{% endif %} \
-o {{ marp_output_pptx }} \
{{ marp_output_markdown }}
when:
- marp_output_pptx is defined
register: marp_pptx_cmd
changed_when: marp_pptx_cmd.rc == 0

- name: Generate pdf agenda with Pandoc
ansible.builtin.shell: |
Expand Down
2 changes: 1 addition & 1 deletion tests/kpa_generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
- hosts: localhost
gather_facts: false
connection: local
name: Use a KPA Project to create Marp & Pandoc markdown fils and their pdf
name: Use a KPA Project to create Marp & Pandoc markdown and slide decks
roles:
- role: ../..

0 comments on commit 6e5b0ff

Please sign in to comment.