Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Modified Kirby CMS index.php passing rendered page through HTML Tidy via PHP HTML Tidy functions
<?php
define('DS', DIRECTORY_SEPARATOR);
// load kirby
require(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php');
// check for a custom site.php
if(file_exists(__DIR__ . DS . 'site.php')) {
require(__DIR__ . DS . 'site.php');
} else {
$kirby = kirby();
}
$config = array(
'indent' => true,
'indent-spaces' => '5',
'quote-ampersand' => true,
'quote-marks' => true,
'indent-cdata' => true,
'enclose-text' => true,
'vertical-space' => true,
'sort-attributes' => 'alpha',
'wrap' => '80',
'output-html' => true,
'break-before-br' => true,
'markup' => true,
'write-back' => true,
'wrap-script-literals' => true,
'wrap-sections' => true,
'quiet' => true,
'error-file' => 'tidy.log');
/* Pass the kirby rendering ($kirby->launch())
through HTML Tidy before sending to client */
$tidy = new tidy();
$tidy->parseString($kirby->launch(), $config, 'utf8');
$tidy->cleanRepair();
echo tidy_get_output($tidy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.