diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index deee113..c912495 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -18,6 +18,7 @@ class Kernel extends HttpKernel \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + \Stolz\HtmlTidy\Middleware::class, ]; /** diff --git a/composer.json b/composer.json index a0ec5ff..c99700c 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^7.0", + "stolz/laravel-html-tidy": "^0.1.1" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 6bea1bf..d3a5536 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a875862ccc0c27fcee12c6892c3e2b32", + "content-hash": "88c4c6682a40e4d392c06df35c52baf4", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -4156,6 +4156,63 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "stolz/laravel-html-tidy", + "version": "0.1.1", + "source": { + "type": "git", + "url": "https://github.com/Stolz/laravel-html-tidy.git", + "reference": "e559ce9a3cbd8f690d27c0eabc6385bb50882cc1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Stolz/laravel-html-tidy/zipball/e559ce9a3cbd8f690d27c0eabc6385bb50882cc1", + "reference": "e559ce9a3cbd8f690d27c0eabc6385bb50882cc1", + "shasum": "" + }, + "require": { + "ext-tidy": "*", + "illuminate/http": "5.*", + "illuminate/support": "5.*", + "php": ">=5.4" + }, + "require-dev": { + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Stolz\\HtmlTidy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stolz", + "homepage": "https://github.com/Stolz/laravel-html-tidy", + "role": "developer" + } + ], + "description": "HTML Tidy middleware for Laravel", + "keywords": [ + "HTML5", + "HTMLtidy", + "Purifier", + "beautifier", + "filter", + "html", + "htmlpurifier", + "indent", + "laravel", + "markup", + "middleware", + "tidy" + ], + "time": "2015-12-28T03:55:57+00:00" + }, { "name": "theseer/tokenizer", "version": "1.1.0", diff --git a/config/app.php b/config/app.php index f2430de..6ebb328 100644 --- a/config/app.php +++ b/config/app.php @@ -166,6 +166,7 @@ return [ App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + Stolz\HtmlTidy\ServiceProvider::class, ], /* diff --git a/config/tidy.php b/config/tidy.php new file mode 100644 index 0000000..2f09b3d --- /dev/null +++ b/config/tidy.php @@ -0,0 +1,69 @@ + extension_loaded('tidy'), + + // Process AJAX requests + 'ajax' => false, + + // Encoding of your original documents. This refers to the encoding that you original documents have, + // not the enconding that will be used for the output. + 'encoding' => 'utf8', // Possible values: ascii, latin0, latin1, raw, utf8, iso2022, mac, win1252, ibm858, utf16, utf16le, utf16be, big5, and shiftjis. + + // Doctype used for the output + 'doctype' => '', + + // Append errors to output + 'display_errors' => false, + + // Errors container opening tag + 'container_open_tag' => '
[x]', + + // Errors container closing tag + 'container_close_tag' => '
', + + // Options passed to HTML Tidy parseString() function. Docs: http://tidy.sourceforge.net/docs/quickref.html + 'tidy_options' => [ + 'output-xhtml' => false, + 'char-encoding' => 'utf8', + 'wrap' => 0, + 'wrap-sections' => false, + 'indent' => 2, // 2 is equivalent to 'auto', which seems to be ignored by PHP-html-tidy extension + 'indent-spaces' => 4, + + // HTML5 workarounds + 'doctype' => 'omit', //The filter will add the configured doctype later + 'new-blocklevel-tags' => 'article,aside,canvas,dialog,embed,figcaption,figure,footer,header,hgroup,nav,output,progress,section,video', + 'new-inline-tags' => 'audio,bdi,command,datagrid,datalist,details,keygen,mark,meter,rp,rt,ruby,source,summary,time,track,wbr', + ], + + // Errors that match these regexs wont be displayed + 'ignored_errors' => [ + // workaround to hide errors related to HTML5 + "/line.* proprietary attribute \"class\"\n?/", + "/line.* proprietary attribute \"autocomplete\"\n?/", + "/line.* proprietary attribute \"autofocus\"\n?/", + "/line.* lacks \"content\" attribute\n?/", + "/line.* proprietary attribute \"charset\"\n?/", + "/line.*