summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--README.md3
-rw-r--r--application/controllers/file.php10
m---------application/third_party/parsedown0
-rw-r--r--docker/Dockerfile2
-rw-r--r--install.php15
-rwxr-xr-xscripts/Markdown.pl147
7 files changed, 10 insertions, 170 deletions
diff --git a/.gitmodules b/.gitmodules
index 8e18180fc..e9b88c03c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,6 @@
[submodule "application/third_party/QrCode"]
path = application/third_party/QrCode
url = https://github.com/endroid/QrCode.git
+[submodule "application/third_party/parsedown"]
+ path = application/third_party/parsedown
+ url = https://github.com/erusev/parsedown.git
diff --git a/README.md b/README.md
index 289ead211..32674564f 100644
--- a/README.md
+++ b/README.md
@@ -40,9 +40,6 @@ not need to register to be allowed to post.
* phar for tarball creation
* mysql, mysqli, pgsql, pdo_mysql (any of those) for database access
-* perl with the following CPAN Modules
- * Text::Markdown for markdown rendering
-
* [pygmentize](http://pygments.org/) for code highlighting
* [ansi2html](http://pypi.python.org/pypi/ansi2html) for shell output rendering (ANSI color codes)
* [imagemagick](http://www.imagemagick.org/) for additional thumbnail generation
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 7c49988bf..79d5395ae 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -320,14 +320,16 @@ class File extends MY_Controller {
echo '<div class="code content table markdownrender">'."\n";
echo '<div class="table-row">'."\n";
echo '<div class="table-cell">'."\n";
- // TODO: use exec safe and catch exception
- $r = (new \libraries\ProcRunner(array(FCPATH.'scripts/Markdown.pl', $file)))->forbid_stderr()->exec();
- echo $r['stdout'];
+
+ require_once(APPPATH."/third_party/parsedown/Parsedown.php");
+ $parsedown = new Parsedown();
+ echo $parsedown->text(file_get_contents($file));
+
echo '</div></div></div>';
return array(
"output" => ob_get_clean(),
- "return_value" => $r["return_code"],
+ "return_value" => 0,
);
} else {
return get_instance()->_colorify($file, $lexer, $is_multipaste ? $filedata["id"] : false);
diff --git a/application/third_party/parsedown b/application/third_party/parsedown
new file mode 160000
+Subproject 490a8f35a4163f59230f53c34f1fbb22a864c01
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 70e82f9e2..8dd4e4e09 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -4,7 +4,7 @@ MAINTAINER Sebastian Rakel <sebastian@devunit.eu>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y && \
- apt-get install -y php5 php5-mysql php5-gd php5-imagick libtext-markdown-perl expect \
+ apt-get install -y php5 php5-mysql php5-gd php5-imagick expect \
python-pygments imagemagick git python-pip realpath curl apt-transport-https
RUN echo 'deb https://deb.nodesource.com/node_4.x trusty main' > /etc/apt/sources.list.d/nodesource.list
diff --git a/install.php b/install.php
index 1deb8cc2a..5287fbebb 100644
--- a/install.php
+++ b/install.php
@@ -29,21 +29,6 @@ $buf = ob_get_contents();
ob_end_clean();
$buf == "works" || $errors .= "passthru() failed\n";
-// test perl deps
-$perldeps = array(
- "Text::Markdown"
-);
-foreach ($perldeps as $dep) {
- ob_start();
- passthru("perl 2>&1 -M'$dep' -e1");
- $buf = ob_get_contents();
- ob_end_clean();
- if ($buf != "") {
- $errors .= " - failed to find perl module: $dep.\n";
- $errors .= $buf;
- }
-}
-
// test pygmentize
ob_start();
passthru("pygmentize -V 2>&1", $buf);
diff --git a/scripts/Markdown.pl b/scripts/Markdown.pl
deleted file mode 100755
index 169b15fed..000000000
--- a/scripts/Markdown.pl
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use Text::Markdown qw(markdown);
-
-=head1 NAME
-
-Markdown.pl - Convert Markdown syntax to (X)HTML
-
-=head1 DESCRIPTION
-
-This program is distributed as part of Perl's Text::Markdown module,
-illustrating sample usage.
-
-Markdown can be invoked on any file containing Markdown-syntax, and
-will produce the corresponding (X)HTML on STDOUT:
-
- $ cat file.txt
- This is a *test*.
-
- Absolutely _nothing_ to see here. _Just a **test**_!
-
- * test
- * Yup, test.
- $ Markdown.pl file.txt
- <p>This is a <em>test</em>.</p>
-
- <p>Absolutely <em>nothing</em> to see here. <em>Just a <strong>test</strong></em>!</p>
-
- <ul>
- <li>test</li>
- <li>Yup, test.</li>
- </ul>
-
-If no file is specified, it will expect its input from STDIN:
-
- $ echo "A **simple** test" | markdown
- <p>A <strong>simple</strong> test</p>
-
-=head1 OPTIONS
-
-=over
-
-=item version
-
-Shows the full information for this version
-
-=item shortversion
-
-Shows only the version number
-
-=item html4tags
-
-Produce HTML 4-style tags instead of XHTML - XHTML requires elements
-that do not wrap a block (i.e. the C<hr> tag) to state they will not
-be closed, by closing with C</E<gt>>. HTML 4-style will plainly output
-the tag as it comes:
-
- $ echo '---' | markdown
- <hr />
- $ echo '---' | markdown --html4tags
- <hr>
-
-=item help
-
-Shows this documentation
-
-=back
-
-=head1 AUTHOR
-
-Copyright 2004 John Gruber
-
-Copyright 2008 Tomas Doran
-
-The manpage was written by Gunnar Wolf <gwolf@debian.org> for its use
-in Debian systems, but can be freely used elsewhere.
-
-For full licensing information, please refer to
-L<Text::Markdown.pm>'s full documentation.
-
-=head1 SEE ALSO
-
-L<Text::Markdown>, L<http://daringfireball.net/projects/markdown/>
-
-=cut
-
-#### Check for command-line switches: #################
-my %cli_opts;
-use Getopt::Long;
-Getopt::Long::Configure('pass_through');
-GetOptions(\%cli_opts,
- 'version',
- 'shortversion',
- 'html4tags',
- 'help',
-);
-if ($cli_opts{'version'}) { # Version info
- print "\nThis is Markdown, version $Text::Markdown::VERSION.\n";
- print "Copyright 2004 John Gruber\n";
- print "Copyright 2008 Tomas Doran\n";
- print "Parts contributed by several other people.";
- print "http://daringfireball.net/projects/markdown/\n\n";
- exit 0;
-}
-if ($cli_opts{'shortversion'}) { # Just the version number string.
- print $Text::Markdown::VERSION;
- exit 0;
-}
-if ($cli_opts{'help'}) {
- for my $dir (split m/:/, $ENV{PATH}) {
- my $cmd = "$dir/perldoc";
- exec($cmd, $0) if (-f $cmd and -x $cmd);
- }
- die "perldoc could not be found in your path - Cannot show help, sorry\n";
-}
-my $m;
-if ($cli_opts{'html4tags'}) { # Use HTML tag style instead of XHTML
- $m = Text::Markdown->new(empty_element_suffix => '>');
-}
-else {
- $m = Text::Markdown->new;
-}
-
-sub main {
- my (@fns) = @_;
-
- my $f;
- if (scalar @fns) {
- foreach my $fn (@fns) {
- die("Cannot find file $fn") unless (-r $fn);
-
- my $fh;
- open($fh, '<', $fn) or die;
- $f = join('', <$fh>);
- close($fh) or die;
- }
- }
- else { # STDIN
- local $/; # Slurp the whole file
- $f = <>;
- }
-
- return $m->markdown($f);
-}
-
-print main(@ARGV) unless caller();