public static void Main(string [] args) { if (args.Length < 1) { Console.Error.WriteLine("usage: wiki2ecma sourcefile [--full]"); return; } bool full = args.Length > 1 && args [1] == "--full"; bool isXml = false; using (Stream s = File.OpenRead(args [0])) { isXml = (s.ReadByte() == '<'); } string text; if (isXml) { XmlDocument doc = new XmlDocument(); doc.Load(args [0]); XmlNode node = doc.SelectSingleNode("//text"); text = node.InnerText; } else { StreamReader sr = new StreamReader(args [0], Encoding.UTF8); text = sr.ReadToEnd(); } // Pass the input Wiki-like content as the .ctor() // parameter. WikiStyleDocConverter p = new WikiStyleDocConverter(text); XmlNode result; if (full) { result = p.ParseEntireDoc(); } else { result = p.ParseContent(); } XmlTextWriter xw = new XmlTextWriter(Console.Out); xw.Formatting = Formatting.Indented; result.WriteTo(xw); xw.Close(); }
public static void Main (string [] args) { if (args.Length < 1) { Console.Error.WriteLine ("usage: wiki2ecma sourcefile [--full]"); return; } bool full = args.Length > 1 && args [1] == "--full"; bool isXml = false; using (Stream s = File.OpenRead (args [0])) { isXml = (s.ReadByte () == '<'); } string text; if (isXml) { XmlDocument doc = new XmlDocument (); doc.Load (args [0]); XmlNode node = doc.SelectSingleNode ("//text"); text = node.InnerText; } else { StreamReader sr = new StreamReader (args [0], Encoding.UTF8); text = sr.ReadToEnd (); } // Pass the input Wiki-like content as the .ctor() // parameter. WikiStyleDocConverter p = new WikiStyleDocConverter (text); XmlNode result; if (full) result = p.ParseEntireDoc (); else result = p.ParseContent (); XmlTextWriter xw = new XmlTextWriter (Console.Out); xw.Formatting = Formatting.Indented; result.WriteTo (xw); xw.Close (); }