Skip to content

Instantly share code, notes, and snippets.

@cedwardsmedia
Created October 18, 2018 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedwardsmedia/b589740d47fb57c9113f30c917269a80 to your computer and use it in GitHub Desktop.
Save cedwardsmedia/b589740d47fb57c9113f30c917269a80 to your computer and use it in GitHub Desktop.
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