public static void Main(string[] args) { try { Console.Write("BBCode: "); string b = Console.ReadLine(); BBCodeParser p = new BBCodeParser(true); p.Parse(b); Console.WriteLine("HTML"); Console.WriteLine(p.ToHTML()); Console.WriteLine("BBCode"); Console.WriteLine(new CodeGenerator().Generate(p.Output)); Console.WriteLine("XML"); Console.WriteLine(new XMLGenerator().Generate(p.Output)); Console.WriteLine("XML Tree"); Console.WriteLine(new XmlTreeGenerator().Generate(p.Output)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
void Button1_Click(object sender, EventArgs e) { try { //BBCode.Strictness = ParseStrictness.IgnoreErrors; webBrowser1.DocumentText = BBCode.Parse(textBox1.Text); BBCodeParser bParser = new BBCodeParser(true); bParser.Strictness = ParseStrictness.IgnoreErrors; bParser.Parse(textBox1.Text); //IGenerator gen = new BBCodes.Visitors.XMLGenerator(); IGenerator gen = new BBCodes.Visitors.CodeGenerator(); //IGenerator gen = new XmlTreeGenerator(); textBox1.Text = gen.Generate(bParser.Output); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }