<?php
namespace Tags;

include('lib/geshi/geshi.php');

class code implements ITagProcessor {
	private static $LANGUAGE_ALIASES=array(
		"c#"=>"csharp",
		"html"=>"html5"
	);
	
	public static function Process($args, $content) {
		if (!isset($args['lang']))
			return $content;
		
		if (isset(self::$LANGUAGE_ALIASES[$args['lang']]))
			$args['lang']=self::$LANGUAGE_ALIASES[$args['lang']];
		
		if (!isset($args['lineStyle']))
			$args['lineStyle']=GESHI_FANCY_LINE_NUMBERS;
		else
			$args['lineStyle']=(int)$args['lineStyle'];
		
		$content=str_replace("\t", "    ", $content);
				
		$geshi=new \GeSHi(trim($content),$args['lang']);
		$geshi->enable_line_numbers($args['lineStyle']);
		$geshi->set_overall_class("code");
		return $geshi->parse_code();
	}
}
