<?php

class WikiTranslatorListMode extends WikiTranslatorMode {



	protected $ordered;



	public function __construct($ordered) {
		$this->ordered = $ordered;
	}



	public function open() {
		return $this->ordered ? '<ol>' : '<ul>';
	}



	public function close() {
		return $this->ordered ? '</ol>' : '</ul>';
	}



	public function parse($ln) {
		return '<li>' . parent::parse(substr($ln, 1)) . '</li>';
	}



	public static function buildIfMatch($ln, WikiTranslatorToC $toc) {
		if ($ln[0] == '*' and $ln[1] == ' ') {
			return new WikiTranslatorListMode(false);
		} elseif ($ln[0] == '#' and $ln[1] == ' ') {
			return new WikiTranslatorListMode(true);
		}
		return null;
	}



} // class WikiTranslatorListMode

?>