Skip to main content

Transform Markdown Templates into Dynamic Content

A powerful toolkit for processing templates with advanced file inclusion capabilities, perfect for prompt engineering, documentation automation, and content generation workflows.

template.md
# Project Documentation

{petk:include src="README.md" start="## Installation"}

{petk:include src="docs/*.md" exclude="drafts"}

Generated on: {petk:var date}
output.md
# Project Documentation

## Installation

Install using npm, pnpm, or yarn:

```bash
npm install -g petk
```

## API Reference
...

Generated on: 2024-01-15

Why use Petk?

Modern development workflows require efficient content generation and template processing. Petk bridges the gap between static templates and dynamic content by providing powerful inclusion directives, variable substitution, and file processing capabilities. Whether you're building documentation systems, generating prompts for LLMs, or automating content workflows, Petk streamlines the process.

Built with TypeScript and functional programming principles, Petk offers reliable performance with comprehensive validation, watch mode for development, and seamless integration into existing build pipelines. The toolkit supports glob patterns, conditional includes, and advanced file ordering to give you precise control over content generation.

From simple file inclusion to complex template orchestration, Petk provides the tools you need to build maintainable, scalable content generation systems that grow with your project requirements.

Key Features

📝

Template Processing

Advanced Markdown template processing with powerful inclusion directives, variable substitution, and conditional logic for dynamic content generation.

👀

Watch Mode

Real-time file watching with intelligent rebuilds. Automatically regenerate content when source files change during development.

🔄

YAML Conversion

Convert Markdown documents to structured YAML format with configurable schemas and validation for data-driven workflows.

🛡️

Validation & Safety

Comprehensive validation with circular dependency detection, path traversal protection, and resource limits for safe template processing.

Installation

Global Installation

npm install -g petk
pnpm add -g petk
yarn global add petk

Project Installation

npm install petk
pnpm add petk
yarn add petk

Quick Start

# Process a template file
petk build template.md -o output.md

# Watch for changes
petk build template.md -w

# Convert to YAML
petk convert document.md -o data.yaml