Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/jonbeebe/frontmatter
- Owner: jonbeebe
- License: isc
- Created: 2017-12-24T10:18:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-08T08:01:57.000Z (11 months ago)
- Last Synced: 2024-12-08T12:48:54.909Z (2 months ago)
- Topics: markdown, python, python-3, yaml, yaml-frontmatter, yaml-parser
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 12
- Watchers: 2
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 linefoo: 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)