All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rjeschke.txtmark.Run Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
/*
 * Copyright (C) 2011-2015 René Jeschke 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.rjeschke.txtmark;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Simple class for processing markdown files on the command line.
 *
 * 

* Usage: *

* *
 * java -cp txtmark.jar txtmark.Run filename [header_footer_file]
 * 
 * 
* *

* The header_footer_file is an optional UTF-8 encoded file * containing a header and a footer to output around the generated HTML code. *

* *

* Example: *

* *
 * <?xml version="1.0" encoding="UTF-8"?>
 * <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 *                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 * <html xmlns="http://www.w3.org/1999/xhtml">
 * <head>
 * <title>markdown</title>
 * <link type="text/css" href="style.css" rel="stylesheet"/>
 * <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
 * </head>
 * <body>
 * <!-- the following line separates header from footer -->
 * <!-- ### -->
 * </body>
 * </html>
 * 
 * 
* * @author René Jeschke <[email protected]> */ public class Run { /** * Static main. * * @param args * Program arguments. * @throws IOException * If an IO error occurred. */ public static void main(final String[] args) throws IOException { // This is just a _hack_ ... BufferedReader reader = null; if (args.length == 0) { System.err.println("No input file specified."); System.exit(-1); } if (args.length > 1) { reader = new BufferedReader(new InputStreamReader(new FileInputStream(args[1]), "UTF-8")); String line = reader.readLine(); while (line != null && !line.startsWith("