4use CGI::Carp 'fatalsToBrowser';
6$CGI::POST_MAX=1024 * 100; # max 100K posts
7$CGI::DISABLE_UPLOADS = 1; # no uploads
9param('url') && param('format') or die "Missing url and/or format parameters.\n";
11my $options = '-r html --standalone --reference-links';
12my $url = param('url');
13my $format = param('format') || 'markdown';
14if ($format =~ /^markdown$/) {
15 $options .= ' --strict';
17if ($format =~ /^markdown\+$/) {
21# Validate URL and format
22unless ($url =~ /^(https?:\/\/)?[\w#_-]+(\.[\w#_-]+)+(:\d+)?[\w\/#=:?_.-]*$/) {
23 die "Illegal URL: $url\n" ;
25unless ($format =~ /^markdown\+?|rst|latex|context|rtf|man|docbook$/) {
26 die "Illegal format: $format\n";
29# Note - pass through head to truncate file to 100K if greater.
30# This should prevent certain kinds of DoS attacks.
31my $output = `wget -O- $url | head -c100000 | tidy -asxhtml -utf8 | pandoc -w $format $options`;
32if ($output =~ /^\s*$/) {
35 p("Either $url could not be retrieved, or its HTML was too malformed to parse."),
39print header(-charset=>"utf8",-type=>"text/plain"),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list