	public static void main(String... args) {
		Params params = new Params();
		JCommander jc = new JCommander(params);
		try {
			jc.parse(args);
		} catch (ParameterException t) {
			usage(jc, t);
		}
		File sourceFolder = new File(params.sourceFolder);
		File destinationFolder = new File(params.outputFolder);
		File[] markdownFiles = sourceFolder.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				return name.toLowerCase().endsWith(".mkd");
			}
		});
		Arrays.sort(markdownFiles);
		Map<String, String> aliasMap = new HashMap<String, String>();
		for (String alias : params.aliases) {
			String[] values = alias.split("=");
			aliasMap.put(values[0], values[1]);
		}
		System.out.println(MessageFormat.format("Generating site from {0} Markdown Docs in {1} ",
				markdownFiles.length, sourceFolder.getAbsolutePath()));
		String linkPattern = "<a href=''{0}''>{1}</a>";
		StringBuilder sb = new StringBuilder();
		for (File file : markdownFiles) {
			String documentName = getDocumentName(file);
			if (!params.skips.contains(documentName)) {
				String displayName = documentName;
				if (aliasMap.containsKey(documentName)) {
					displayName = aliasMap.get(documentName);
				}
				String fileName = documentName + ".html";
				sb.append(MessageFormat.format(linkPattern, fileName, displayName));
				sb.append(" | ");
			}
		}
		sb.setLength(sb.length() - 3);
		sb.trimToSize();
		String htmlHeader = FileUtils.readContent(new File(params.pageHeader), "\n");
		String htmlAdSnippet = null;
		if (!StringUtils.isEmpty(params.adSnippet)) {
			File snippet = new File(params.adSnippet);
			if (snippet.exists()) {
				htmlAdSnippet = FileUtils.readContent(snippet, "\n");
			}
		}
		String htmlFooter = FileUtils.readContent(new File(params.pageFooter), "\n");
		String links = sb.toString();
		String header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links);
		if (!StringUtils.isEmpty(params.analyticsSnippet)) {
			File snippet = new File(params.analyticsSnippet);
			if (snippet.exists()) {
				String htmlSnippet = FileUtils.readContent(snippet, "\n");
				header = header.replace("<!-- ANALYTICS -->", htmlSnippet);
			}
		}
		final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		final String footer = MessageFormat.format(htmlFooter, "generated " + date);
		for (File file : markdownFiles) {
			try {
				String documentName = getDocumentName(file);
				if (!params.skips.contains(documentName)) {
					String fileName = documentName + ".html";
					System.out.println(MessageFormat.format("  {0} => {1}", file.getName(),
							fileName));
					InputStreamReader reader = new InputStreamReader(new FileInputStream(file),
							Charset.forName("UTF-8"));
					String content = MarkdownUtils.transformMarkdown(reader);
					for (String token : params.substitutions) {
						String[] kv = token.split("=");
						content = content.replace(kv[0], kv[1]);
					}
					for (String alias : params.properties) {
						String[] kv = alias.split("=");
						String loadedContent = generatePropertiesContent(new File(kv[1]));
						content = content.replace(kv[0], loadedContent);
					}
					for (String alias : params.loads) {
						String[] kv = alias.split("=");
						String loadedContent = FileUtils.readContent(new File(kv[1]), "\n");
						loadedContent = StringUtils.escapeForHtml(loadedContent, false);
						loadedContent = StringUtils.breakLinesForHtml(loadedContent);
						content = content.replace(kv[0], loadedContent);
					}
					OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
							new File(destinationFolder, fileName)), Charset.forName("UTF-8"));
					writer.write(header);
					if (!StringUtils.isEmpty(htmlAdSnippet)) {
						writer.write(htmlAdSnippet);
					}
					writer.write(content);
					writer.write(footer);
					reader.close();
					writer.close();
				}
			} catch (Throwable t) {
				System.err.println("Failed to transform " + file.getName());
				t.printStackTrace();
			}
		}
	}

	public static void main(String... args) {
		Params params = new Params();
		JCommander jc = new JCommander(params);
		try {
			jc.parse(args);
		} catch (ParameterException t) {
			usage(jc, t);
		}
		File sourceFolder = new File(params.sourceFolder);
		File destinationFolder = new File(params.outputFolder);
		File[] markdownFiles = sourceFolder.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				return name.toLowerCase().endsWith(".mkd");
			}
		});
		Arrays.sort(markdownFiles);
		Map<String, String> aliasMap = new HashMap<String, String>();
		for (String alias : params.aliases) {
			String[] values = alias.split("=");
			aliasMap.put(values[0], values[1]);
		}
		System.out.println(MessageFormat.format("Generating site from {0} Markdown Docs in {1} ",
				markdownFiles.length, sourceFolder.getAbsolutePath()));
		String linkPattern = "<a href=''{0}''>{1}</a>";
		StringBuilder sb = new StringBuilder();
		for (File file : markdownFiles) {
			String documentName = getDocumentName(file);
			if (!params.skips.contains(documentName)) {
				String displayName = documentName;
				if (aliasMap.containsKey(documentName)) {
					displayName = aliasMap.get(documentName);
				} else {
					displayName = displayName.replace('_', ' ');
				}
				String fileName = documentName + ".html";
				sb.append(MessageFormat.format(linkPattern, fileName, displayName));
				sb.append(" | ");
			}
		}
		sb.setLength(sb.length() - 3);
		sb.trimToSize();
		String htmlHeader = FileUtils.readContent(new File(params.pageHeader), "\n");
		String htmlAdSnippet = null;
		if (!StringUtils.isEmpty(params.adSnippet)) {
			File snippet = new File(params.adSnippet);
			if (snippet.exists()) {
				htmlAdSnippet = FileUtils.readContent(snippet, "\n");
			}
		}
		String htmlFooter = FileUtils.readContent(new File(params.pageFooter), "\n");
		String links = sb.toString();
		String header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links);
		if (!StringUtils.isEmpty(params.analyticsSnippet)) {
			File snippet = new File(params.analyticsSnippet);
			if (snippet.exists()) {
				String htmlSnippet = FileUtils.readContent(snippet, "\n");
				header = header.replace("<!-- ANALYTICS -->", htmlSnippet);
			}
		}
		final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		final String footer = MessageFormat.format(htmlFooter, "generated " + date);
		for (File file : markdownFiles) {
			try {
				String documentName = getDocumentName(file);
				if (!params.skips.contains(documentName)) {
					String fileName = documentName + ".html";
					System.out.println(MessageFormat.format("  {0} => {1}", file.getName(),
							fileName));
					InputStreamReader reader = new InputStreamReader(new FileInputStream(file),
							Charset.forName("UTF-8"));
					String content = MarkdownUtils.transformMarkdown(reader);
					for (String token : params.substitutions) {
						String[] kv = token.split("=");
						content = content.replace(kv[0], kv[1]);
					}
					for (String alias : params.properties) {
						String[] kv = alias.split("=");
						String loadedContent = generatePropertiesContent(new File(kv[1]));
						content = content.replace(kv[0], loadedContent);
					}
					for (String alias : params.loads) {
						String[] kv = alias.split("=");
						String loadedContent = FileUtils.readContent(new File(kv[1]), "\n");
						loadedContent = StringUtils.escapeForHtml(loadedContent, false);
						loadedContent = StringUtils.breakLinesForHtml(loadedContent);
						content = content.replace(kv[0], loadedContent);
					}
					OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
							new File(destinationFolder, fileName)), Charset.forName("UTF-8"));
					writer.write(header);
					if (!StringUtils.isEmpty(htmlAdSnippet)) {
						writer.write(htmlAdSnippet);
					}
					writer.write(content);
					writer.write(footer);
					reader.close();
					writer.close();
				}
			} catch (Throwable t) {
				System.err.println("Failed to transform " + file.getName());
				t.printStackTrace();
			}
		}
	}
