Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2020-01-18 18:51:45 +0300
committerPhie <phie@phie.ovh>2020-01-18 18:51:45 +0300
commit7fd2415ac11b80947dd316f27bcbed8e3f3dc3d5 (patch)
tree1478812d48de6a333c688f1b593e6eb646df44a7 /lib
parent5ede689271793a10641031d0a2b67391886b538d (diff)
keep new lines for lists
Diffstat (limited to 'lib')
-rw-r--r--lib/Misc/NoteUtils.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Misc/NoteUtils.php b/lib/Misc/NoteUtils.php
index c137052..f9231c0 100644
--- a/lib/Misc/NoteUtils.php
+++ b/lib/Misc/NoteUtils.php
@@ -2,8 +2,23 @@
namespace OCA\Carnet\Misc;
class NoteUtils{
public static $defaultCarnetNotePath = "Documents/QuickNote";
- public static function getShortTextFromHTML($html){
- return mb_substr(trim(preg_replace('#<[^>]+>#', ' ', $html)),0, 150);
+ public static function getShortTextFromHTML($html){ //not optimized at alllll....
+ return mb_substr(
+ //remove first and last br
+ preg_replace('/^(<br\s*\/?>)*|(<br\s*\/?>)*$/i', '',
+ //multiple to single br
+ preg_replace('/(<br[^>]*>\s*){2,}/', '<br/>',
+ //white spaces
+ trim(
+ //putting back [linebr] to br
+ str_replace('[linebr]', '<br>',
+ //removing html tags
+ preg_replace('#<[^>]+>#', ' ',
+ //replacing all br by linebr
+ preg_replace('/(<br\ ?\/?>)/', '[linebr]',
+ //all div to [linebr]
+ preg_replace("/<div>(.*?)<\/div>/", "[linebr]$1",$html)
+ )))))),0, 150);
}
public function getMetadata($carnetFolder, $path){
$meta = array();