protected static function generate_alt($html, $wordwrap, $newline)
	{
		$html = preg_replace('/[ |	]{2,}/m', ' ', $html);
		$html = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $html)));
		$lines = explode($newline, $html);
		$result = array();
		$first_newline = true;
		foreach ($lines as $line)
		{
			$line = trim($line);
			if ( ! empty($line) or $first_newline)
			{
				$first_newline = false;
				$result[] = $line;
			}
			else
			{
				$first_newline = true;
			}
		}

		$html = join($newline, $result);

		if ( ! $wordwrap)
		{
			return $html;
		}

		return wordwrap($html, $wordwrap, $newline, true);
	}