Skip to main content

Process a directory of files with frontmatter and middleware

Project description

# Metalsmyth

[![Build Status](](

This is a little library to process a directory of files with a stack of middleware. It is based on [metalsmith](, which is built in and for Node. This version uses the same three-step process:

1. Read all the files in a source directory.
2. Invoke a series of plugins that manipulate the files.
3. Write the results to a destination directory!

Each plugin is simply a callable that takes a dictionary of files, plus a `Stack` instance, and does something. It doesn't actually have to operate on (or return) the files. Each file is parsed for YAML Frontmatter, with file paths as keys (relative to the source directory).

A few plugins are included by default:

- drafts: filter out posts where `draft` is `true`
- dates: convert a date field to a Python `datetime.datetime` object
- markdown: convert post content to HTML using markdown
- bleach: run `bleach.clean` on post content
- linkify: run `bleach.linkify` on post content

## Install

$ pip install metalsmyth

By itself, Metalsmyth only needs [Python Frontmatter][fm], which itself relies on [PyYAML][]. If you want to use the bundled plugins, you'll need a few extra libraries:

$ pip install markdown # for markdown plugin
$ pip install bleach # for bleach and linkify plugins
$ pip install jinja2 # for jinja template plugin
$ pip install python-dateutil # for dates plugin


## Usage

from metalsmyth import Stack
from metalsmyth.plugins.dates import Dates
from metalsmyth.plugins.markup import Bleach, Markdown

# create a stack with a source directory and middleware
stack = Stack('tests/markup',

# get processed files
files =

# or build to a destination directory'tests/tmp')

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for metalsmyth, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size metalsmyth-0.1.4.tar.gz (11.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page