Skip to content

Instantly share code, notes, and snippets.

@ultramookie
Created June 19, 2021 17:40
Show Gist options
  • Save ultramookie/735614f2e0c23c0b23b61df94809e2e1 to your computer and use it in GitHub Desktop.
Save ultramookie/735614f2e0c23c0b23b61df94809e2e1 to your computer and use it in GitHub Desktop.
Protocode for parsing the YAML Front Matter for Hugo docs.
#!/bin/env python3
import yaml
from yaml.loader import SafeLoader
import pprint
DELIMITER = "---\n"
filename = "infinite.md"
_, yaml_text, _ = open(filename).read().split(DELIMITER, maxsplit=2)
data = yaml.load_all(yaml_text, Loader=SafeLoader)
for doc in data:
print(doc["title"])
print(doc["release_year"])
print(doc["rating"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment