// TxtToHtml.java
//
// You may use and distribute this example. This program is 
// provided WITHOUT WARRANTY either expressed or implied.
//
// Copyright Henrik Björkman 1997
//
// This program uses Piped Input and Output Streams to send a 
// stream of data through a number of filter programs. Each of 
// these filter programs is a thread reading from an input and 
// writing to an output stream. For the first filter the input 
// is a file and for the last the output is system out.
//
// History:
// 0.0 Created by Henrik Björkman 1997-06-14 (from Replace.java)
// 0.1 Making headlines also. Henrik 10/10
// 0.2 Using se.beod.henrik.filter.*. Henrik 1998-06-07


import java.io.*;
import se.beod.henrik.filter.*;


public class TxtToHtml
{
  static PipedInputStream in;
  static PipedOutputStream out;
  static PipedInputStream next_in;

  // This function is called before each filter thread is created
  // To create an input output pair of piped stream and set up the
  // in and out to be used by the filter thread to be started.
  static void setupInOut() throws IOException
  {
    in=next_in;
    out=new PipedOutputStream();
    next_in=new PipedInputStream(out);
  }

  public static void main(String args[]) 
  {
    if (args.length < 1 )
    {
      System.out.println("Usage: java TxtToHtml <filename>");
      System.exit(0);
    }
        
    try 
    {

       setupInOut();
       new MakeLinks(new FileInputStream(args[0]),out);

       setupInOut();
       new MakeHeadline(in,out);

       setupInOut();
       new AddHtml(in,System.out);


    }
    catch (IOException e) { System.err.println("TxtToHtml: " + e); }
  }
}


