Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonbeebe/frontmatter

A simple Python package for parsing YAML Frontmatter from a text file or string.
https://github.com/jonbeebe/frontmatter

markdown python python-3 yaml yaml-frontmatter yaml-parser

Last synced: about 2 months ago
JSON representation

A simple Python package for parsing YAML Frontmatter from a text file or string.

Awesome Lists containing this project

README

        

frontmatter
============

A simple Python package for parsing YAML Frontmatter from a text file or string. Written for Python 3, but should also work for Python 2.7.

Usage
------

```
from frontmatter import Frontmatter

# assuming 'testfile.md' exists
post = Frontmatter.read_file('testfile.md')

print(post['attributes'], "\n") # Dictionary
print(post['body'], "\n") # String
print(post['frontmatter']) # String
```

The output would be:

```
{'foo': 'bar', 'num': 3, 'list': ['first', 'second', 'third']}

This is the actual post content
This is a second line

foo: bar
num: 3
list:
- first
- second
- third
```

In the above example, the contents of **testfile.md** is:

```
---
foo: bar
num: 3
list:
- first
- second
- third
---

This is the actual post content
This is a second line
```

LICENSE
--------

[ISC License](https://en.wikipedia.org/wiki/ISC_license)