li3_docs\doc\Docblock::_clean()

protected method

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

string

Source

	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);
	}