public string Format(string Document, string HighlighterName, bool IncludeLineNumbers) { HtmlWriter writer = new HtmlWriter(); writer.ShowLineNumbers = IncludeLineNumbers; writer.AlternateLineBackground = false; string generatedHtml = writer.GenerateHtml(Document, HighlighterName); return "<html><body>" + generatedHtml + "</body></html>"; }
public static void Main(string[] args) { HtmlWriter w = new HtmlWriter(); w.ShowLineNumbers = true; w.AlternateLineBackground = true; string code = File.ReadAllText("../../Main.cs"); string html = w.GenerateHtml(code, "C#"); File.WriteAllText("output.html", "<html><body>" + html + "</body></html>"); Process.Start("output.html"); // view in browser }
public static void Main(string[] args) { IHighlightingDefinition highlightDefinition = HighlightingManager.Instance.GetDefinition("C#"); HtmlWriter w = new HtmlWriter(); w.ShowLineNumbers = true; w.AlternateLineBackground = true; string code = File.ReadAllText("../../Main.cs"); string html = w.GenerateHtml(code, highlightDefinition); File.WriteAllText("output.html", "<html><body>" + html + "</body></html>"); Process.Start("output.html"); // view in browser }
protected void formatCode_Click(object sender, EventArgs e) { HtmlWriter writer = new HtmlWriter(); writer.ShowLineNumbers = ShowLineNumbers.Checked; writer.AlternateLineBackground = UseAlternatingBackground.Checked; string generatedHtml = writer.GenerateHtml(inputTextBox.Text, languageChoice.SelectedValue); string codeHtmlDocument = "<html><body>" + generatedHtml + "</body></html>"; outputTextBox.Text = codeHtmlDocument; inlineCodePreview.Text = generatedHtml; PreviewPane.Visible = true; }
public static void Main(string[] args) { IHighlightingDefinition highlightDefinition = null; var _assembly = Assembly.GetExecutingAssembly(); using (Stream s = File.OpenRead("GherkinDefinition.xshd")) { using (XmlTextReader reader = new XmlTextReader(s)) { highlightDefinition = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } HtmlWriter w = new HtmlWriter(); w.ShowLineNumbers = false; w.CreateStylesheet = false; w.AlternateLineBackground = false; string code = File.ReadAllText("../../SampleFeature.txt"); string html = w.GenerateHtml(code, highlightDefinition); File.WriteAllText("output.html", "<html><body>" + html + "</body></html>"); Process.Start("output.html"); // view in browser }
internal MyHtmlOptions(HtmlWriter htmlWriter) { this.htmlWriter = htmlWriter; }