diff options
author | Michael Vogel <icarus@dabo.de> | 2012-03-18 17:52:51 +0100 |
---|---|---|
committer | Michael Vogel <icarus@dabo.de> | 2012-03-18 17:52:51 +0100 |
commit | 6f10142b2e4f65dd17157fee462e17ff370ab903 (patch) | |
tree | 1fa8eeda0da8d52bf8dde5acb42d697e5af08898 /include/html2plain.php | |
parent | f5db142d93906d9fd33ddcd75dfa56ec90ce3b9e (diff) | |
download | volse-hubzilla-6f10142b2e4f65dd17157fee462e17ff370ab903.tar.gz volse-hubzilla-6f10142b2e4f65dd17157fee462e17ff370ab903.tar.bz2 volse-hubzilla-6f10142b2e4f65dd17157fee462e17ff370ab903.zip |
API: Seesmic is now working. Optimizing text export.
Diffstat (limited to 'include/html2plain.php')
-rw-r--r-- | include/html2plain.php | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/include/html2plain.php b/include/html2plain.php index 2a4cf6639..d367d7c1f 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -1,9 +1,13 @@ <?php require_once "html2bbcode.php"; -function breaklines($line, $level) +function breaklines($line, $level, $wraplength = 75) { - $wraplen = 75-$level; + + if ($wraplength == 0) + return($line); + + $wraplen = $wraplength-$level; $newlines = array(); @@ -37,7 +41,7 @@ function breaklines($line, $level) return(implode($newlines, "\n")); } -function quotelevel($message) +function quotelevel($message, $wraplength = 75) { $lines = explode("\n", $message); @@ -65,12 +69,12 @@ function quotelevel($message) } if (!$startquote or ($line != '')) - $newlines[] = breaklines($line, $currlevel); + $newlines[] = breaklines($line, $currlevel, $wraplength); } return(implode($newlines, "\n")); } -function html2plain($html) +function html2plain($html, $wraplength = 75) { global $lang; @@ -99,7 +103,7 @@ function html2plain($html) foreach ($result as $treffer) { if ($treffer[1] == $treffer[2]) { - $search = '<a href="'.$treffer[1].'" target="_blank">'.$treffer[1].'</a>'; + $search = '<a href="'.$treffer[1].'" target="external-link">'.$treffer[1].'</a>'; $message = str_replace($search, $treffer[1], $message); } } @@ -109,6 +113,7 @@ function html2plain($html) node2bbcode($doc, 'body', array(), '', ''); // MyBB-Auszeichnungen + /* node2bbcode($doc, 'span', array('style'=>'text-decoration: underline;'), '_', '_'); node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '/', '/'); node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '*', '*'); @@ -117,6 +122,7 @@ function html2plain($html) node2bbcode($doc, 'b', array(), '*', '*'); node2bbcode($doc, 'i', array(), '/', '/'); node2bbcode($doc, 'u', array(), '_', '_'); + */ node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n"); @@ -143,10 +149,11 @@ function html2plain($html) node2bbcode($doc, 'h5', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h6', array(), "\n\n*", "*\n"); - node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1', '', true); - node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', ''); - node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); - node2bbcode($doc, 'img', array(), '', ''); + // 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, 'img', array('alt'=>'/(.+)/'), '$1', ''); + //node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); + //node2bbcode($doc, 'img', array(), '', ''); node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]'); $message = $doc->saveHTML(); @@ -173,7 +180,7 @@ function html2plain($html) $message = str_replace("\n\n\n", "\n\n", $message); } while ($oldmessage != $message); - $message = quotelevel(trim($message)); + $message = quotelevel(trim($message), $wraplength); return(trim($message)); } |