$npx -y skills add berabuddies/Semia --skill md-to-officeConvert Markdown to Word, PowerPoint, and PDF using Pandoc - the universal document converter
| 1 | # Markdown to Office Skill |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | This skill enables conversion from Markdown to various Office formats using **Pandoc** - the universal document converter. Convert your Markdown files to professional Word documents, PowerPoint presentations, PDFs, and more while preserving formatting and structure. |
| 6 | |
| 7 | ## How to Use |
| 8 | |
| 9 | 1. Provide the Markdown content or file |
| 10 | 2. Specify the target format (docx, pptx, pdf, etc.) |
| 11 | 3. Optionally provide a reference template for styling |
| 12 | 4. I'll convert using Pandoc with optimal settings |
| 13 | |
| 14 | **Example prompts:** |
| 15 | - "Convert this README.md to a professional Word document" |
| 16 | - "Turn my markdown notes into a PowerPoint presentation" |
| 17 | - "Generate a PDF from this markdown with custom styling" |
| 18 | - "Create a Word doc from this markdown using company template" |
| 19 | |
| 20 | ## Domain Knowledge |
| 21 | |
| 22 | ### Pandoc Fundamentals |
| 23 | |
| 24 | ```bash |
| 25 | # Basic conversion |
| 26 | pandoc input.md -o output.docx |
| 27 | pandoc input.md -o output.pdf |
| 28 | pandoc input.md -o output.pptx |
| 29 | |
| 30 | # With template |
| 31 | pandoc input.md --reference-doc=template.docx -o output.docx |
| 32 | |
| 33 | # Multiple inputs |
| 34 | pandoc ch1.md ch2.md ch3.md -o book.docx |
| 35 | ``` |
| 36 | |
| 37 | ### Supported Conversions |
| 38 | |
| 39 | | From | To | Command | |
| 40 | |------|-----|---------| |
| 41 | | Markdown | Word | `pandoc in.md -o out.docx` | |
| 42 | | Markdown | PDF | `pandoc in.md -o out.pdf` | |
| 43 | | Markdown | PowerPoint | `pandoc in.md -o out.pptx` | |
| 44 | | Markdown | HTML | `pandoc in.md -o out.html` | |
| 45 | | Markdown | LaTeX | `pandoc in.md -o out.tex` | |
| 46 | | Markdown | EPUB | `pandoc in.md -o out.epub` | |
| 47 | |
| 48 | ### Markdown to Word (.docx) |
| 49 | |
| 50 | #### Basic Conversion |
| 51 | ```bash |
| 52 | pandoc document.md -o document.docx |
| 53 | ``` |
| 54 | |
| 55 | #### With Template (Reference Doc) |
| 56 | ```bash |
| 57 | # First create a template by converting sample |
| 58 | pandoc sample.md -o reference.docx |
| 59 | |
| 60 | # Edit reference.docx styles in Word, then use it |
| 61 | pandoc input.md --reference-doc=reference.docx -o output.docx |
| 62 | ``` |
| 63 | |
| 64 | #### With Table of Contents |
| 65 | ```bash |
| 66 | pandoc document.md --toc --toc-depth=3 -o document.docx |
| 67 | ``` |
| 68 | |
| 69 | #### With Metadata |
| 70 | ```bash |
| 71 | pandoc document.md \ |
| 72 | --metadata title="My Report" \ |
| 73 | --metadata author="John Doe" \ |
| 74 | --metadata date="2024-01-15" \ |
| 75 | -o document.docx |
| 76 | ``` |
| 77 | |
| 78 | ### Markdown to PDF |
| 79 | |
| 80 | #### Via LaTeX (Best Quality) |
| 81 | ```bash |
| 82 | # Requires LaTeX installation |
| 83 | pandoc document.md -o document.pdf |
| 84 | |
| 85 | # With custom settings |
| 86 | pandoc document.md \ |
| 87 | --pdf-engine=xelatex \ |
| 88 | -V geometry:margin=1in \ |
| 89 | -V fontsize=12pt \ |
| 90 | -o document.pdf |
| 91 | ``` |
| 92 | |
| 93 | #### Via HTML/wkhtmltopdf |
| 94 | ```bash |
| 95 | pandoc document.md \ |
| 96 | --pdf-engine=wkhtmltopdf \ |
| 97 | --css=style.css \ |
| 98 | -o document.pdf |
| 99 | ``` |
| 100 | |
| 101 | #### PDF Options |
| 102 | ```bash |
| 103 | pandoc document.md \ |
| 104 | -V papersize:a4 \ |
| 105 | -V geometry:margin=2cm \ |
| 106 | -V fontfamily:libertinus \ |
| 107 | -V colorlinks:true \ |
| 108 | --toc \ |
| 109 | -o document.pdf |
| 110 | ``` |
| 111 | |
| 112 | ### Markdown to PowerPoint (.pptx) |
| 113 | |
| 114 | #### Basic Conversion |
| 115 | ```bash |
| 116 | pandoc slides.md -o presentation.pptx |
| 117 | ``` |
| 118 | |
| 119 | #### Markdown Structure for Slides |
| 120 | ```markdown |
| 121 | --- |
| 122 | title: Presentation Title |
| 123 | author: Author Name |
| 124 | date: January 2024 |
| 125 | --- |
| 126 | |
| 127 | # Section Header (creates section divider) |
| 128 | |
| 129 | ## Slide Title |
| 130 | |
| 131 | - Bullet point 1 |
| 132 | - Bullet point 2 |
| 133 | - Sub-bullet |
| 134 | |
| 135 | ## Another Slide |
| 136 | |
| 137 | Content here |
| 138 | |
| 139 | ::: notes |
| 140 | Speaker notes go here (not visible in slides) |
| 141 | ::: |
| 142 | |
| 143 | ## Slide with Image |
| 144 | |
| 145 | {width=80%} |
| 146 | |
| 147 | ## Two Column Slide |
| 148 | |
| 149 | :::::::::::::: {.columns} |
| 150 | ::: {.column width="50%"} |
| 151 | Left column content |
| 152 | ::: |
| 153 | |
| 154 | ::: {.column width="50%"} |
| 155 | Right column content |
| 156 | ::: |
| 157 | :::::::::::::: |
| 158 | ``` |
| 159 | |
| 160 | #### With Template |
| 161 | ```bash |
| 162 | # Use corporate PowerPoint template |
| 163 | pandoc slides.md --reference-doc=template.pptx -o presentation.pptx |
| 164 | ``` |
| 165 | |
| 166 | ### YAML Frontmatter |
| 167 | |
| 168 | Add metadata at the top of your Markdown: |
| 169 | |
| 170 | ```yaml |
| 171 | --- |
| 172 | title: "Document Title" |
| 173 | author: "Author Name" |
| 174 | date: "2024-01-15" |
| 175 | abstract: "Brief description" |
| 176 | toc: true |
| 177 | toc-depth: 2 |
| 178 | numbersections: true |
| 179 | geometry: margin=1in |
| 180 | fontsize: 11pt |
| 181 | documentclass: report |
| 182 | --- |
| 183 | |
| 184 | # First Chapter |
| 185 | ... |
| 186 | ``` |
| 187 | |
| 188 | ### Python Integration |
| 189 | |
| 190 | ```python |
| 191 | import subprocess |
| 192 | import os |
| 193 | |
| 194 | def md_to_docx(input_path, output_path, template=None): |
| 195 | """Convert Markdown to Word document.""" |
| 196 | cmd = ['pandoc', input_path, '-o', output_path] |
| 197 | |
| 198 | if template: |
| 199 | cmd.extend(['--reference-doc', template]) |
| 200 | |
| 201 | subprocess.run(cmd, check=True) |
| 202 | return output_path |
| 203 | |
| 204 | def md_to_pdf(input_path, output_path, **options): |
| 205 | """Convert Markdown to PDF with options.""" |
| 206 | cmd = ['pandoc', input_path, '-o', output_path] |
| 207 | |
| 208 | if options.get('toc'): |
| 209 | cmd.append('--toc') |
| 210 | |
| 211 | if options.get('margin'): |
| 212 | cmd.extend(['-V', f"geometry:margin={options['margin']}"]) |
| 213 | |
| 214 | subprocess.run(cmd, check=True) |
| 215 | return output_path |
| 216 | |
| 217 | def md_to_pptx(input_path, output_path, template=None): |
| 218 | """Convert Markdown to PowerPoint.""" |
| 219 | cmd = ['pan |