Get the FREE Ultimate OpenClaw Setup Guide →
P

md-to-office

Scanned

@PiyushDuggal-source

npx machina-cli add skill @PiyushDuggal-source/pandic-office --openclaw
Files (1)
SKILL.md
2.6 KB

Local Pandoc Conversion Skill

This skill uses the pandoc command-line utility to convert documents between numerous markup formats.

Basic Usage

The fundamental structure of a pandoc command is:

pandoc [options] [input-file]…

Simple Conversion

To convert a Markdown file to HTML:

pandoc -o output.html input.md

Specifying Formats

While pandoc can infer formats from file extensions, you can be explicit with the -f (from) and -t (to) flags.

# Convert HTML to Markdown
pandoc -f html -t markdown input.html

Standalone Documents

To create a complete document with a proper header and footer (e.g., a full HTML file), use the -s or --standalone flag.

pandoc -s -o output.html input.md

Advanced Examples

The following examples are extracted from the official Pandoc User's Guide.

PDF Output

To create a PDF, pandoc typically uses a LaTeX engine. Ensure one is installed.

# Basic PDF creation
pandoc input.md -o output.pdf

# Control PDF engine and style via variables
pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=1in -V fontsize=12pt

Document Structure & Metadata

Pandoc can automatically generate a table of contents and use document metadata.

# Create a document with a Table of Contents (up to level 3 headings)
pandoc --toc --toc-depth=3 -o output.docx input.md

# Set metadata fields from the command line
pandoc -M title:"My Report" -M author:"Galactus" -o output.pdf input.md

Templates and Styling

You can control the final output's structure and style with templates and other options.

# Use a custom template for HTML output
pandoc -s --template=my-template.html -o output.html input.md

# For HTML output, link to a custom CSS file
pandoc -s --css=styles.css -o output.html input.md

# For DOCX output, use a reference document for styling
pandoc --reference-doc=reference.docx -o output.docx input.md

Reading from the Web

Pandoc can directly fetch and convert content from a URL.

pandoc -f html -t markdown https://www.fsf.org

Other Useful Options

# Preserve tabs instead of converting them to spaces
pandoc --preserve-tabs ...

# Control line wrapping in the output source code
pandoc --wrap=none ...

# Shift heading levels (e.g., make all H1s into H2s, H2s into H3s)
pandoc --shift-heading-level-by=1 ...

This enhanced documentation provides a more robust foundation for using pandoc.

Source

git clone https://clawhub.ai/PiyushDuggal-source/pandic-officeView on GitHub

Overview

This skill uses pandoc to convert Markdown files (.md) into PDF documents. It relies on a LaTeX engine to render the final output and supports metadata, templates, and layout adjustments for polished reports.

How This Skill Works

Pandoc reads the Markdown input and emits a PDF via a LaTeX backend. The common workflow is pandoc input.md -o output.pdf, with options like -s for standalone documents, --pdf-engine to choose the engine, and -M to set metadata. Advanced styling can be controlled with templates or a reference LaTeX document.

When to Use It

  • You need to convert a .md file to a PDF when a user requests a printable document.
  • You want a standalone PDF with a proper header and footer (-s) for distribution.
  • You need to adjust layout or typography using -V geometry, -V fontsize, or --pdf-engine.
  • You want to embed metadata such as a title or author directly in the PDF (-M title, -M author).
  • You require a Table of Contents in the PDF using --toc and --toc-depth.

Quick Start

  1. Step 1: Install pandoc and a LaTeX engine (e.g., TeX Live or MiKTeX).
  2. Step 2: Run pandoc input.md -o output.pdf to generate the PDF.
  3. Step 3: Optional flags like -s, --pdf-engine, -M metadata, or --toc to tailor the output.

Best Practices

  • Ensure a LaTeX engine (TeX Live or MiKTeX) is installed before generating PDFs.
  • Use -s to create a standalone document with proper structure.
  • Use -M title and -M author to embed metadata in the PDF.
  • Leverage --toc and --toc-depth for navigable long documents.
  • If styling is needed, supply a LaTeX template or a reference document via --template or --reference-doc.

Example Use Cases

  • pandoc input.md -o output.pdf
  • pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=1in -V fontsize=12pt
  • pandoc -M title:My Report -M author:Galactus -o output.pdf input.md
  • pandoc -s --template=my-template.tex -o output.pdf input.md
  • pandoc --toc --toc-depth=3 -o output.pdf input.md

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers