Created
June 19, 2021 17:40
-
-
Save ultramookie/735614f2e0c23c0b23b61df94809e2e1 to your computer and use it in GitHub Desktop.
Protocode for parsing the YAML Front Matter for Hugo docs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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