From 3a013ad02eb263a751ec1310837065fac581b81e Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 6 Feb 2019 13:50:16 +0000 Subject: Automatically convert markdown to HTML. --- cat.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'cat.php') diff --git a/cat.php b/cat.php index 25afa6f..e43b75e 100644 --- a/cat.php +++ b/cat.php @@ -20,6 +20,7 @@ require 'config.php'; require 'common.php'; +require 'Parsedown.php'; global $config; @@ -31,7 +32,17 @@ $cmd = $config['svn'] . ' cat --non-interactive ' . '--password=' . $config['password'] . ' ' . escapeshellarg($url); -header('Content-Type: ' . GuessMimeType($fname)); -header('Content-Disposition: inline; filename="' . $fname . '"'); -passthru($cmd); +if (IsMarkdown($fname)) +{ + header('Content-Type: text/html'); + $output = shell_exec($cmd); + $pd = new Parsedown(); + echo $pd->text($output); +} +else +{ + header('Content-Type: ' . GuessMimeType($fname)); + header('Content-Disposition: inline; filename="' . $fname . '"'); + passthru($cmd); +} ?> -- cgit v1.2.3