summaryrefslogtreecommitdiff
path: root/lib/helpers.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helpers.php')
-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;
}