conditional markdown preprocessing
authorAndrew Lorimer <andrew@lorimer.id.au>
Sat, 9 Sep 2023 02:44:23 +0000 (12:44 +1000)
committerAndrew Lorimer <andrew@lorimer.id.au>
Sat, 9 Sep 2023 02:44:23 +0000 (12:44 +1000)
gitweb/gitweb.perl
index 6ddde75deec8b7f974495d7b5fde4fcde78720a6..e60bc31ad84c11e53ba5cc621962a0501dc9b740 100755 (executable)
@@ -16,6 +16,7 @@
 use filetest 'access';
 use HTML::Entities;
 use Pandoc;
+use Text::Markdown qw(markdown);
 use CGI qw(:standard :escapeHTML -nosticky);
 use CGI::Util qw(unescape);
 #use CGI::Carp qw(fatalsToBrowser set_message);  # debugging only
@@ -6922,9 +6923,13 @@ sub git_summary {
 
                 # Process markdown if necessary
                 if ($readme_file =~ /\.md$/i && check_pandoc()) {
-                  $filecontents = pandoc->parse('markdown' => $filecontents)->to_html;
+                  #$filecontents = pandoc->parse('markdown' => $filecontents)->to_html;
+                  $filecontents = markdown($filecontents);;
+                  print($filecontents);
+                }
+                else {
+                  print($cgi->escapeHTML($filecontents));
                 }
-                print($filecontents);
 
                 close $fd
                   or die_error(500, "Error processing readme file $hash");