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();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlFormatter"/> class with given <paramref name="options"/>
 /// </summary>
 /// <param name="options">Configuration details for the <see cref="HtmlFormatter"/></param>
 public HtmlFormatter(HtmlFormatterOptions options)
 {
     Options = options;
     _style = Options.Style ?? new DefaultStyle();
     CreateStylesheet();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlFormatter"/> class with given <paramref name="options"/>
 /// </summary>
 /// <param name="options">Configuration details for the <see cref="HtmlFormatter"/></param>
 public HtmlFormatter(HtmlFormatterOptions options)
 {
     Options = options;
     _style  = Options.Style ?? new DefaultStyle();
     CreateStylesheet();
 }
        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>");
        }