From 6e77e0358abff4fe1997a9da882fae35c44a277a Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Tue, 24 Jun 2025 19:46:28 +0400 Subject: init: first commit --- scripts/parse_frontmatter.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 scripts/parse_frontmatter.py (limited to 'scripts/parse_frontmatter.py') diff --git a/scripts/parse_frontmatter.py b/scripts/parse_frontmatter.py new file mode 100644 index 0000000..2d5c60e --- /dev/null +++ b/scripts/parse_frontmatter.py @@ -0,0 +1,19 @@ +import yaml + +def parse_frontmatter(filepath): + with open(filepath, 'r', encoding='utf-8') as f: + lines = f.readlines() + + if not lines or lines[0].strip() != '---': + return {} + + frontmatter_lines = [] + for line in lines[1:]: + if line.strip() == '---': + break + frontmatter_lines.append(line) + + frontmatter_str = ''.join(frontmatter_lines) + frontmatter = yaml.safe_load(frontmatter_str) or {} + + return frontmatter -- cgit v1.2.3