Skip to main content
# Metalsmyth

[![Build Status](https://travis-ci.org/eyeseast/python-metalsmyth.svg)](https://travis-ci.org/eyeseast/python-metalsmyth)

This is a little library to process a directory of files with a stack of middleware. It is based on [metalsmith](http://www.metalsmith.io/), 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

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

# create a stack with a source directory, destination and middleware
stack = Stack('tests/markup', 'tests/tmp',
Dates('date'),
Bleach(strip=True),
Markdown(output_format='html5')
)

# get processed files
files = stack.run()

# or build to stack.dest
stack.build()
```

Metadata

Release files for metalsmyth 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metalsmyth 0.1.1
File Size Uploaded
metalsmyth-0.1.1.tar.gz 10.6 kB Details

Release files / metalsmyth-0.1.1.tar.gz

Download URL metalsmyth-0.1.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
59dc18cf005e10894f7695a159ceea035810de0f60a39fbdc7bba8c8effb8f65
BLAKE2b-256 checksum
How to use checksums
3bc736f9949d4ae64346507caa51a857d944f990373dbbff50f050c0c71ce312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.6

2 release files

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page