// Path: src/main/java/com/cadrlife/jhaml/JHamlConfig.java
// public class JHamlConfig {
// 	public static final int OUTPUT_INDENTATION_SIZE = 2;
// 	public static final ImmutableList<String> validFormats = ImmutableList.of("xhtml","html4","html5");
// 	public String format = "xhtml";
// 	public List<String> autoclose = Lists.newArrayList("meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base");
// 	public List<String> preserve = Lists.newArrayList("textarea", "pre");
// 	public String attrWrapper = "'";
// 	
// 	public Map<String,Filter> filters = new HashMap<String,Filter>();
// 	{
// 		filters.put("plain", new PlainFilter(this));
// 		filters.put("javascript", new JavaScriptFilter(this));
// 		filters.put("cdata", new CdataFilter(this));
// 		filters.put("escaped", new EscapedFilter(this));
// 		filters.put("preserve", new PreserveFilter(this));
// 		filters.put("jsp", new JspFilter(this));
// 		filters.put("css", new CssFilter(this));
// 		filters.put("markdown", new MarkdownFilter(this));
// 	}
// 	
// 	public boolean isXhtml() {
// 		return !isHtml();
// 	}
// 	public boolean isHtml() {
// 		return isHtml4() || isHtml5();
// 	}
// 	public boolean isHtml4() {
// 		return "html4".equals(this.format);
// 	}
// 	public boolean isHtml5() {
// 		return "html5".equals(this.format);
// 	}
// 	
// 	// These options escapeHtml, suppressEval, and encoding may not be necessary.
// 	//	boolean escapeHtml = false;
// 	//	boolean suppressEval = false;
// 	//	String encoding = "utf-8";
// }
// 
// Path: src/main/java/com/cadrlife/jhaml/internal/util/IndentUtils.java
// public class IndentUtils {
// private static final CharMatcher INDENTATION_MATCHER = CharMatcher.anyOf("\t ");
// 
// 	//	public static String rebaseIndent(String text, int amount) {
// //		String current = spaces(baseIndentation(text));
// //		String textWithoutFirstIndent = CharMatcher.is(' ').trimLeadingFrom(text);
// //		String target = spaces(amount);
// //		return target + textWithoutFirstIndent.replaceAll("\n", "\n"+target ); 
// //	}
// 	public static String indent(String text, int amount) {
// 		if (amount >= 0) {
// 			String target = spaces(amount);
// 			return target + text.replaceAll("\n", "\n"+target).replaceAll("\n"+target+"\\z", "\n"); 
// 		}
// 		if (text.length() < -amount || !INDENTATION_MATCHER.matchesAllOf(text.substring(0,-amount))) {
// 			return text;
// 		}
// 		return text.substring(-amount).replaceAll("\n" + spaces(-amount), "\n");
// 	}
// 	
// 	public static String spaces(int spaces) {
// 		String string = "";
// 		for (int i = 0; i<spaces; i++) {
// 			string += " ";
// 		}
// 		return string;
// 	}
//  
// 	public static int baseIndentation(String text) {
// 		return text.length() - INDENTATION_MATCHER.trimLeadingFrom(text).length();
// 	}
// 
// 	public static boolean containsNesting(String text) {
// 		return text.contains("\n" + spaces(baseIndentation(text)+1));
// 	}
// 
// 	public static boolean hasContentOnFirstLine(String text) {
// 		int endOfFirstLine = text.contains("\n") ? text.indexOf('\n') : text.length();
// 		return StringUtils.isNotBlank(text.substring(0, endOfFirstLine));
// 	}
// 
// 	public static String describe(boolean isIndentWithTabs, int indentationSize) {
// 		return indentationSize + (isIndentWithTabs ? " tab" : " space") + (indentationSize == 1 ? "" : "s");
// 	}
// 
// 	public static String describe(String indentation) {
// 		if (CharMatcher.is('\t').matchesAllOf(indentation)) {
// 			return describe(true, indentation.length());
// 		}
// 		if (CharMatcher.is(' ').matchesAllOf(indentation)) {
// 			return describe(false, indentation.length());
// 		}
// 		return "\"" + indentation.replaceAll("\t", "\\\\t")+ "\"";
// 	}
// }


import com.cadrlife.jhaml.JHamlConfig;
import com.google.common.base.CharMatcher;
import com.cadrlife.jhaml.internal.util.IndentUtils;

package com.cadrlife.jhaml.filters;


public abstract class Filter {
	protected final JHamlConfig config;

	public Filter(JHamlConfig config) {
		this.config = config;
	}
	
	public abstract String process(String input);
	
	protected String indent(String text, int amount) {

// Path: src/main/java/com/cadrlife/jhaml/JHamlConfig.java
// public class JHamlConfig {
// 	public static final int OUTPUT_INDENTATION_SIZE = 2;
// 	public static final ImmutableList<String> validFormats = ImmutableList.of("xhtml","html4","html5");
// 	public String format = "xhtml";
// 	public List<String> autoclose = Lists.newArrayList("meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base");
// 	public List<String> preserve = Lists.newArrayList("textarea", "pre");
// 	public String attrWrapper = "'";
// 	
// 	public Map<String,Filter> filters = new HashMap<String,Filter>();
// 	{
// 		filters.put("plain", new PlainFilter(this));
// 		filters.put("javascript", new JavaScriptFilter(this));
// 		filters.put("cdata", new CdataFilter(this));
// 		filters.put("escaped", new EscapedFilter(this));
// 		filters.put("preserve", new PreserveFilter(this));
// 		filters.put("jsp", new JspFilter(this));
// 		filters.put("css", new CssFilter(this));
// 		filters.put("markdown", new MarkdownFilter(this));
// 	}
// 	
// 	public boolean isXhtml() {
// 		return !isHtml();
// 	}
// 	public boolean isHtml() {
// 		return isHtml4() || isHtml5();
// 	}
// 	public boolean isHtml4() {
// 		return "html4".equals(this.format);
// 	}
// 	public boolean isHtml5() {
// 		return "html5".equals(this.format);
// 	}
// 	
// 	// These options escapeHtml, suppressEval, and encoding may not be necessary.
// 	//	boolean escapeHtml = false;
// 	//	boolean suppressEval = false;
// 	//	String encoding = "utf-8";
// }
// 
// Path: src/main/java/com/cadrlife/jhaml/internal/util/IndentUtils.java
// public class IndentUtils {
// private static final CharMatcher INDENTATION_MATCHER = CharMatcher.anyOf("\t ");
// 
// 	//	public static String rebaseIndent(String text, int amount) {
// //		String current = spaces(baseIndentation(text));
// //		String textWithoutFirstIndent = CharMatcher.is(' ').trimLeadingFrom(text);
// //		String target = spaces(amount);
// //		return target + textWithoutFirstIndent.replaceAll("\n", "\n"+target ); 
// //	}
// 	public static String indent(String text, int amount) {
// 		if (amount >= 0) {
// 			String target = spaces(amount);
// 			return target + text.replaceAll("\n", "\n"+target).replaceAll("\n"+target+"\\z", "\n"); 
// 		}
// 		if (text.length() < -amount || !INDENTATION_MATCHER.matchesAllOf(text.substring(0,-amount))) {
// 			return text;
// 		}
// 		return text.substring(-amount).replaceAll("\n" + spaces(-amount), "\n");
// 	}
// 	
// 	public static String spaces(int spaces) {
// 		String string = "";
// 		for (int i = 0; i<spaces; i++) {
// 			string += " ";
// 		}
// 		return string;
// 	}
//  
// 	public static int baseIndentation(String text) {
// 		return text.length() - INDENTATION_MATCHER.trimLeadingFrom(text).length();
// 	}
// 
// 	public static boolean containsNesting(String text) {
// 		return text.contains("\n" + spaces(baseIndentation(text)+1));
// 	}
// 
// 	public static boolean hasContentOnFirstLine(String text) {
// 		int endOfFirstLine = text.contains("\n") ? text.indexOf('\n') : text.length();
// 		return StringUtils.isNotBlank(text.substring(0, endOfFirstLine));
// 	}
// 
// 	public static String describe(boolean isIndentWithTabs, int indentationSize) {
// 		return indentationSize + (isIndentWithTabs ? " tab" : " space") + (indentationSize == 1 ? "" : "s");
// 	}
// 
// 	public static String describe(String indentation) {
// 		if (CharMatcher.is('\t').matchesAllOf(indentation)) {
// 			return describe(true, indentation.length());
// 		}
// 		if (CharMatcher.is(' ').matchesAllOf(indentation)) {
// 			return describe(false, indentation.length());
// 		}
// 		return "\"" + indentation.replaceAll("\t", "\\\\t")+ "\"";
// 	}
// }


// Path: src/main/java/com/cadrlife/jhaml/filters/Filter.java
import com.cadrlife.jhaml.JHamlConfig;
import com.google.common.base.CharMatcher;
import com.cadrlife.jhaml.internal.util.IndentUtils;

package com.cadrlife.jhaml.filters;


public abstract class Filter {
	protected final JHamlConfig config;

	public Filter(JHamlConfig config) {
		this.config = config;
	}
	
	public abstract String process(String input);
	
	protected String indent(String text, int amount) {

		return IndentUtils.indent(text, amount);
