summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-02-03 14:51:11 -0800
committerAaron Parecki <aaron@parecki.com>2017-02-03 14:51:11 -0800
commit1894da9452edaf1f2b3de5a6a969d60844645a23 (patch)
tree6aa2059218ce871c2f2583bb99df8a4ff76f0103 /lib
parentd00c336a55d1dd047cdb778cb44ae441ea6b842e (diff)
indent the HTML sent from the editor
Diffstat (limited to 'lib')
-rw-r--r--lib/helpers.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index 26faf49..f5dc13d 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -382,12 +382,15 @@ function correct_photo_rotation($filename) {
}
function sanitize_editor_html($html) {
+ #error_log($html."\n");
+
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$config->set('HTML.AllowedElements', [
'a',
'abbr',
'b',
+ 'br',
'code',
'del',
'em',
@@ -425,5 +428,18 @@ function sanitize_editor_html($html) {
$sanitized = str_replace('<p><br /></p>','',$sanitized);
$sanitized = str_replace('<p></p>','',$sanitized);
+ $indenter = new \Gajus\Dindent\Indenter([
+ 'indentation_character' => ' '
+ ]);
+ $indenter->setElementType('h1', \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
+ $indenter->setElementType('h2', \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
+ $indenter->setElementType('h3', \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
+ $indenter->setElementType('h4', \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
+ $indenter->setElementType('h5', \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
+ $indenter->setElementType('h6', \Gajus\Dindent\Indenter::ELEMENT_TYPE_INLINE);
+ $sanitized = $indenter->indent($sanitized);
+
+ #error_log($sanitized."\n");
+
return $sanitized;
}