(function() {
	
	angular.module('communityHTMLFilter', ['ngSanitize']).filter('communityHTMLFilter', function() {
		
		return function(input, readOnlyMode) {
			
			if (readOnlyMode) {
				var tree = angular.element('<div>'+input+'</div>');//defensively wrap in a div to avoid 'invalid html' exception
				tree.find('a').attr('target', '_blank'); //manipulate the parse tree
				return angular.element('<div>').append(tree).html(); //trick to have a string representation
			}
			else {
				return input;
			}
			
		};
		
	});
	
})();
