diff options
Diffstat (limited to 'src/web/helpers/markdown.php')
| -rw-r--r-- | src/web/helpers/markdown.php | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/web/helpers/markdown.php b/src/web/helpers/markdown.php deleted file mode 100644 index 5279a1f..0000000 --- a/src/web/helpers/markdown.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php /* Copyright (c) 2024 Freya Murphy */ - -class MarkdownParser { - - private $parsedown; - - function __construct() { - $this->parsedown = new ParsedownExtra(); - } - - /** - * @return array<string,mixed> - */ - function parse(string $path): array { - $content = file_get_contents($path); - $data = array( - 'meta' => array(), - 'content' => $content - ); - if (str_starts_with($content, '---')) { - $parts = explode('---', $content); - $data['content'] = trim(implode('---', array_slice($parts, 2))); - $meta = array_filter(explode("\n", $parts[1]), fn($x) => $x != ''); - foreach ($meta as $set) { - $parts = explode(": ", $set); - $key = trim($parts[0]); - $value = trim($parts[1]); - $data['meta'][$key] = $value; - } - - } - $data['content'] = $this->parsedown->text($data['content']); - return $data; - } - -} |