From ec56c284355afc3a65e4087ccff2cc4c0a17421d Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 10 Jan 2018 22:06:57 -0300 Subject: [PATCH] Moving markdown function to a helpers file --- app/helpers.php | 22 ++++++++++++++++++++++ composer.json | 9 ++++++--- routes/web.php | 21 +-------------------- storage/logs/.gitignore | 0 4 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 app/helpers.php mode change 100644 => 100755 storage/logs/.gitignore diff --git a/app/helpers.php b/app/helpers.php new file mode 100644 index 0000000..4313148 --- /dev/null +++ b/app/helpers.php @@ -0,0 +1,22 @@ +addExtension(new TableExtension()); + + $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment)); + + return $converter->convertToHtml($text); + } +} diff --git a/composer.json b/composer.json index 40a9200..b78a530 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,10 @@ ], "psr-4": { "App\\": "app/" - } + }, + "files": [ + "app/helpers.php" + ] }, "autoload-dev": { "classmap": [ @@ -46,7 +49,7 @@ ] } }, - + "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" @@ -57,7 +60,7 @@ "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover" - ], + ], "post-install-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postInstall" ], diff --git a/routes/web.php b/routes/web.php index 469efd2..7ffcc91 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,28 +10,9 @@ | contains the "web" middleware group. Now create something great! | */ -use League\CommonMark\Converter; -use League\CommonMark\DocParser; -use League\CommonMark\Environment; -use League\CommonMark\HtmlRenderer; -use Webuni\CommonMark\TableExtension\TableExtension; -/** - * Convert some text to Markdown... - */ -if (!function_exists('markdown')) { - function markdown($text) - { - $environment = Environment::createCommonMarkEnvironment(); - $environment->addExtension(new TableExtension()); - - $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment)); - - return $converter->convertToHtml($text); - } -} Route::get('/', 'DocumentationController@landing'); -Route::get('/imprint', function(){ +Route::get('/imprint', function () { return view('imprint')->with('title', 'Imprint'); }); diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore old mode 100644 new mode 100755