/// <summary> /// /// </summary> /// <param name="component">Associated editor</param> private EdxDocument(XmlControl component) { this.editor = component.HtmlEditor; this.nativeRootControl = component; //prepare the validating reader for accepting HTML characters xhtmlContext = Util.CreateXhtmlContext(); xs = new XmlReaderSettings(); xs.ProhibitDtd = false; xs.ValidationType = ValidationType.None; xs.XmlResolver = Util.CreateXhtmlResolver(); // Namespace resolver xmlnsEdx = Util.CreateEdxNamespaceManager(); fo = new HtmlFormatterOptions(' ', 1, 1024, true); formatter = new HtmlFormatter(); }
public void TestLineNumbers() { var options = new HtmlFormatterOptions() { LineNumbers = LineNumberStyle.Table }; var input = SampleFile.Load("csharp-sample.txt"); var tokens = new CSharpLexer() .GetTokens(input); var subject = new HtmlFormatter(options); var output = new StringWriter(); subject.Format(tokens, output); var html = output.ToString(); Check.That(Regex.IsMatch(html, @"<pre>\s+1\s+2\s+3")) .IsTrue(); }
public void TestLineAnchors() { var options = new HtmlFormatterOptions() { LineAnchors = "foo", AnchorLineNumbers = true }; var input = SampleFile.Load("csharp-sample.txt"); var tokens = new CSharpLexer() .GetTokens(input); var subject = new HtmlFormatter(options); var output = new StringWriter(); subject.Format(tokens, output); var html = output.ToString(); Check.That(Regex.IsMatch(html, "<a name=\"foo-1\">")) .IsTrue(); }
public void Full() { var options = new HtmlFormatterOptions() { Full = true, Title = "My Source Code" }; var input = SampleFile.Load("csharp-sample.txt"); var tokens = new CSharpLexer() .GetTokens(input); var subject = new HtmlFormatter(options); var output = new StringWriter(); subject.Format(tokens, output); var html = output.ToString(); File.WriteAllText("output.html", html); Check.That(html).Contains("<html>", "<head>", "<title>My Source Code</title>"); }