public static function convert($html, $options = array()) {

		if ($options === false || $options === true) {
			// Using old style (< 1.0) of passing in options
			$options = array('ignore_errors' => $options);
		}

		$options = array_merge(static::defaultOptions(), $options);

		// check all options are valid
		foreach ($options as $key => $value) {
			if (!in_array($key, array_keys(static::defaultOptions()))) {
				throw new \InvalidArgumentException("Unknown html2text option '$key'");
			}
		}

		$is_office_document = static::isOfficeDocument($html);

		if ($is_office_document) {
			// remove office namespace
			$html = str_replace(array("<o:p>", "</o:p>"), "", $html);
		}

		$html = static::fixNewlines($html);
		if (mb_detect_encoding($html, "UTF-8", true)) {
			$html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");
		}

		$doc = static::getDocument($html, $options['ignore_errors']);

		$output = static::iterateOverNode($doc, null, false, $is_office_document, $options);

		// process output for whitespace/newlines
		$output = static::processWhitespaceNewlines($output);

		return $output;
	}