Skip to content

akatakritos/PygmentSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PygmentSharp

Build Status

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

Installation

Get it from Nuget: PygmentSharp.Core

Usage

// 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

About

C# Port of Pygments syntax highlighter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages