Local Pandoc:AI 智能体文档转换工具 - Openclaw Skills

作者:互联网

2026-03-23

AI教程

什么是 Local Pandoc?

Local Pandoc 技能将行业标准的文档转换功能带入您的自动化工作流。通过将此功能集成到 Openclaw Skills 中,AI 智能体可以无缝衔接技术 Markdown 文档与精美的、可分发的格式。无论您是需要生成独立的 HTML 页面还是排版专业的 PDF,此技能都提供了在本地处理复杂标记转换所需的接口。

除了简单的格式转换外,该技能还支持高级文档处理功能,包括模板应用、元数据管理和 CSS 样式设置。对于使用 Openclaw Skills 自动化文档管线和报告任务的开发人员及内容创作者来说,这是一个必不可少的工具。

下载入口:https://github.com/openclaw/skills/tree/main/skills/piyushduggal-source/pandic-office

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install pandic-office

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 pandic-office。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Local Pandoc 应用场景

  • 从技术 Markdown 笔记生成专业的 PDF 报告。
  • 将 GitHub README 文件转换为面向业务利益相关者的 DOCX 格式。
  • 创建带有自定义 CSS 样式的独立 HTML 文档以用于 Web 托管。
  • 从实时 URL 提取内容并将其直接转换为 Markdown 以进行本地处理。
  • 在大量项目文件中标准化文档标题级别和结构。
Local Pandoc 工作原理
  1. AI 智能体接收转换特定文件或内容字符串的请求。
  2. 该技能识别源格式(如 Markdown)和所需的目标格式(如 PDF、DOCX)。
  3. Openclaw Skills 触发本地 pandoc 二进制文件,并带有用于样式、元数据和引擎选择的适当标志。
  4. 如果需要 PDF 输出,该技能将利用 xelatex 等 LaTeX 引擎来渲染最终文档。
  5. 转换后的文件保存在本地文件系统中,供用户访问。

Local Pandoc 配置指南

要在 Openclaw Skills 中使用此技能,您必须在本地计算机上安装 Pandoc。如果您打算生成 PDF 文件,则还需要安装 LaTeX 发行版。

# 在 macOS 上使用 Homebrew 安装 Pandoc
brew install pandoc

# 在 Linux (Ubuntu/Debian) 上安装 Pandoc
sudo apt-get update
sudo apt-get install pandoc

# (可选) 安装用于 PDF 支持的 LaTeX 引擎
sudo apt-get install texlive-full

Local Pandoc 数据架构与分类体系

Local Pandoc 技能通过结构化的命令行界面处理数据。下表描述了该技能处理的主要数据输入:

组件 描述
输入格式 通过 -f 标志自动检测或定义(例如 gfm, html, docx)
输出格式 由扩展名或 -t 标志定义的目标文件类型
元数据 通过 -M 注入的键值对(例如作者、标题、日期)
变量 通过 -V 传递的样式变量,用于 PDF/LaTeX 控制
模板 用于品牌定制的自定义 .html.docx 参考文件路径
name: local-pandoc
description: Converts Markdown files to PDF files using the pandoc command-line utility. Use when a user asks to convert a .md or markdown file to a .pdf file.

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.