<?php

abstract class WikiTranslatorMode {



	public function open() { }



	public function close() { }



	public function parse($ln) {
		$ln = htmlentities($ln, ENT_COMPAT, 'UTF-8');
		$ln = preg_replace("/'''([^']*)'''/", '<strong>$1</strong>', $ln);
		$ln = preg_replace("/''([^']*)''/", '<em>$1</em>', $ln);
		$ln = preg_replace("/\[([^\]]*)\|([^\]]*)\]/", '<a href="$1">$2</a>', $ln);
		$ln = preg_replace("/\[([^\]]*)\]/", '<a href="$1">$1</a>', $ln);
		return $ln;
	}



	/**
	 * Matches given string and returns mode instance
	 *
	 * @param string
	 * @param WikiTranslatorToC
	 * @return null or WikiTanslatorMode
	 */
	abstract public static function buildIfMatch($ln, WikiTranslatorToC $toc);



} // class WikiTranslatorMode

?>