feat: add highlighting Markdown parser <3

This commit is contained in:
David Bailey 2024-01-22 16:22:11 +01:00
parent 8e69a9139f
commit 9354f9f556
6 changed files with 613 additions and 50 deletions

View file

@ -6,6 +6,7 @@ require_once 'vendor/autoload.php';
require_once 'post_adapter.php';
require_once 'fontawesome.php';
require_once 'dergdown.php';
use Symfony\Component\Yaml\Yaml;
@ -31,6 +32,12 @@ use Twig\Extra\Markdown\DefaultMarkdown;
use Twig\Extra\Markdown\MarkdownRuntime;
use Twig\RuntimeLoader\RuntimeLoaderInterface;
function dergdown_to_html($text) {
$Parsedown = new Dergdown();
return $Parsedown->text($text);
}
function deduce_user_agent() {
$real_agent=$_SERVER['HTTP_USER_AGENT'];
@ -109,6 +116,8 @@ function render_twig($template, $args = []) {
$args['age_gate'] = (!isset($_COOKIE['AgeConfirmed'])) && isset($SITE_CONFIG['age_gate']);
$args['content_html'] ??= dergdown_to_html($post['post_content'] ?? '');
echo $twig->render($template, $args);
}