improve newline handling, remove redundant newlines

This commit is contained in:
mappu 2015-11-08 11:35:43 +13:00
parent d67c7fc926
commit fc28e8c5c8
1 changed files with 10 additions and 2 deletions

View File

@ -213,15 +213,23 @@ class CProject {
$this->shortdesc = array_shift($parts);
$this->shortdesc[0] = strtolower($this->shortdesc[0]); // cosmetic lowercase
// Filter longdesc
// Filter longdesc
$this->longdesc = str_replace("\r", "", $this->longdesc); // filter windows CR
$prefix_html = '';
$this->longdesc = preg_replace_callback('~\r?\nWritten in ([^\\r\\n]+)~ms', function($matches) use (&$prefix_html) {
$this->longdesc = preg_replace_callback('~\r?\nWritten in ([^\\n]+)~ms', function($matches) use (&$prefix_html) {
$prefix_html .= (
(SHIELDS_PREFIX ? mkshield('build', 'success', 'brightgreen').' ' : '').
mkshield('written in', $matches[1], 'blue')
);
return '';
}, $this->longdesc);
while(strpos($this->longdesc, "\n\n\n") !== false) {
$this->longdesc = str_replace("\n\n\n", "\n\n", $this->longdesc);
}
$this->longdesc = rtrim($this->longdesc, "\n");
$this->prefix_html = $prefix_html;
continue;