summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--composer.json3
-rw-r--r--composer.lock47
-rw-r--r--lib/helpers.php16
3 files changed, 64 insertions, 2 deletions
diff --git a/composer.json b/composer.json
index 0061d5d..6a6448d 100644
--- a/composer.json
+++ b/composer.json
@@ -14,7 +14,8 @@
"ezyang/htmlpurifier": "4.*",
"p3k/multipart": "*",
"tantek/cassis": "*",
- "p3k/timezone": "*"
+ "p3k/timezone": "*",
+ "gajus/dindent": "^2.0"
},
"autoload": {
"files": [
diff --git a/composer.lock b/composer.lock
index 4cdfe08..891f3ed 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "1eb78fb0a7afe487cc3c9dd58d35532e",
+ "content-hash": "05f646a93f2c1204dddd80c4670dcf15",
"packages": [
{
"name": "abraham/twitteroauth",
@@ -232,6 +232,51 @@
"time": "2015-06-22T23:26:39+00:00"
},
{
+ "name": "gajus/dindent",
+ "version": "2.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/gajus/dindent.git",
+ "reference": "d81c3a6f78fbe1ab26f5e753098bbbef6b6a9f3c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/gajus/dindent/zipball/d81c3a6f78fbe1ab26f5e753098bbbef6b6a9f3c",
+ "reference": "d81c3a6f78fbe1ab26f5e753098bbbef6b6a9f3c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3"
+ },
+ "require-dev": {
+ "satooshi/php-coveralls": "dev-master"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Gajus\\Dindent\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Gajus Kuizinas",
+ "email": "gk@anuary.com"
+ }
+ ],
+ "description": "HTML indentation library for development and testing.",
+ "homepage": "https://github.com/gajus/dindent",
+ "keywords": [
+ "format",
+ "html",
+ "indent"
+ ],
+ "time": "2014-10-08T10:03:04+00:00"
+ },
+ {
"name": "indieauth/client",
"version": "0.1.13",
"source": {
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;
}