li3_docs\doc\Docblock::_clean()
Cleans a (multi-line) description string by removing multiple whitespaces in front of lists (so they parse correctly), removes trailing and leading whitespaces on lines that are not contained in a markdown fenced code block.
Parameters
-
string
$string;
Returns
stringSource
protected function _clean($string) {
$parts = explode("\n", $string);
$code = false;
foreach ($parts as &$part) {
if (strpos($part, '```') !== false) {
$code = !$code;
}
$part = $code ? rtrim($part) : trim($part);
}
return implode("\n", $parts);
}