A port of python's Pygments syntax highlighter.
Aims to follow the overall approach (for now) while still being mostly idiomatic c#.
Roadmap:
I need the following features from Pygment for my static blog generator. Other features can be ported by the community as needed.
- HTML Output
- C# Highlighting
- SQL Highlighting
- HTML Highlighting
- Javascript Highlighting
- CSS Highlighting
- XML Highlighting
- Shell script highlighting
- PHP Highlighting
- Ruby Highlighting
Get it from Nuget: PygmentSharp.Core
// basic case, specify lexer and formatter
var highlighted = Pygmentize.Content("class Foo {}")
.WithLexer(new CSharpLexer())
.WithFormatter(new HtmlFormatter())
.AsString();
// Common overloads get their own fluent command
var highlighted = Pygmentize.Content("class Foo { }")
.WithLexer(new CSharpLexer())
.ToHtml()
.AsString();
// It will support inference for input and output types
Pygmentize.File("test.cs") // infers language from extension
.ToFile("output.html"); // infers output formatter from extension