diff options
author | Ian C <ianc@noddybox.co.uk> | 2019-02-06 13:50:16 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2019-02-06 13:50:16 +0000 |
commit | 3a013ad02eb263a751ec1310837065fac581b81e (patch) | |
tree | f88c5867232c6118d6a3f0f20dc4c8d45f6e245e /cat.php | |
parent | 3825efd8ca52f6c8c5471168b016fb4d10f482b7 (diff) |
Automatically convert markdown to HTML.
Diffstat (limited to 'cat.php')
-rw-r--r-- | cat.php | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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); +} ?> |