summaryrefslogtreecommitdiff
path: root/cat.php
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2019-02-06 13:50:16 +0000
committerIan C <ianc@noddybox.co.uk>2019-02-06 13:50:16 +0000
commit3a013ad02eb263a751ec1310837065fac581b81e (patch)
treef88c5867232c6118d6a3f0f20dc4c8d45f6e245e /cat.php
parent3825efd8ca52f6c8c5471168b016fb4d10f482b7 (diff)
Automatically convert markdown to HTML.
Diffstat (limited to 'cat.php')
-rw-r--r--cat.php17
1 files changed, 14 insertions, 3 deletions
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);
+}
?>