X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fhtml2plain.php;h=f09087e0b0179fab68fb4e42328ba5037dbabf61;hb=a162ea725139bee852e2dee6f5963a6d34106fee;hp=dfb577abe18018714b4518dd4319ec457addc18e;hpb=c308bb904236deeadd9f996f387bd3002d17b934;p=friendica.git diff --git a/include/html2plain.php b/include/html2plain.php index dfb577abe1..f09087e0b0 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -114,11 +114,11 @@ function html2plain($html, $wraplength = 75, $compact = false) $message = str_replace("\r", "", $html); // replace all hashtag addresses - if (get_config("system", "remove_hashtags_on_export")) { +/* if (get_config("system", "remove_hashtags_on_export")) { $pattern = '/#(.*?)<\/a>/is'; $message = preg_replace($pattern, '#$2', $message); } - +*/ $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; @@ -185,15 +185,15 @@ function html2plain($html, $wraplength = 75, $compact = false) node2bbcode($doc, 'h6', array(), "\n\n*", "*\n"); // Problem: there is no reliable way to detect if it is a link to a tag or profile - //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', '', true); - node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true); + //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true); + //node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true); //node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', ''); //node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); //node2bbcode($doc, 'img', array(), '', ''); if (!$compact) - node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]'); + node2bbcode($doc, 'img', array('src'=>'/(.+)/'), ' [img]$1', '[/img] '); else - node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '', ''); + node2bbcode($doc, 'img', array('src'=>'/(.+)/'), ' ', ' '); node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), ' $1 ', '', true); @@ -218,12 +218,13 @@ function html2plain($html, $wraplength = 75, $compact = false) $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); - if (!$compact) { + if (!$compact AND ($message != "")) { $counter = 1; foreach ($urls as $id=>$url) - if (strpos($message, $url) === false) - $message .= "\n".$url." "; - //$message .= "\n[".($counter++)."] ".$url; + if ($url != "") + if (strpos($message, $url) === false) + $message .= "\n".$url." "; + //$message .= "\n[".($counter++)."] ".$url; } $message = str_replace("\n«", "«\n", $message); @@ -238,4 +239,4 @@ function html2plain($html, $wraplength = 75, $compact = false) return(trim($message)); } - +?>