ColorfulCode 1.0.0-preview1

This is a prerelease version of ColorfulCode.
dotnet add package ColorfulCode --version 1.0.0-preview1
                    
NuGet\Install-Package ColorfulCode -Version 1.0.0-preview1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ColorfulCode" Version="1.0.0-preview1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ColorfulCode" Version="1.0.0-preview1" />
                    
Directory.Packages.props
<PackageReference Include="ColorfulCode" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ColorfulCode --version 1.0.0-preview1
                    
#r "nuget: ColorfulCode, 1.0.0-preview1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ColorfulCode&version=1.0.0-preview1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ColorfulCode&version=1.0.0-preview1&prerelease
                    
Install as a Cake Tool

ColorfulCode

Nuget Repository Size GitHub

ColorfulCode is a syntax highlighter library for C#/.NET Core that uses sublime-text syntax definitions. It is a wrapper for native rust library syntect.

Benefit from syntect syntax highlighting engine, ColorfulCode is very fast. See the performance of syntect for more info.

Getting Started

Installation

ColorfulCode is available as a NuGet package from nuget.org. It can be added to a project in a numbers of ways, depending on the project type and tools used:

dotnet CLI
$ dotnet add package ColorfulCode --version 1.0.0-preview1 
Visual Studio
PM> Install-Package ColorfulCode -Version 1.0.0-preview1
.csproj
<PackageReference Include="ColorfulCode" Version="1.0.0-preview1" />

Supported Platforms

ColorfulCode runs on the following platforms and .NET Core versions:

OS Version Architectures .NET Runtimes
macOS > 10.12 x64 3.1 / 3.0 / 2.1
Linux x86 / x64 3.1 / 3.0 / 2.1
Windows x86 / x64 3.1 / 3.0 / 2.1

Example Code

Prints highlighted html of C# source code to the terminal:

using ColorfulCode;

// get a syntax
SyntaxSet ss = SyntaxSet.LoadDefaults();
Syntax syntax = ss.FindByExtension("cs");  // syntax for C#

// get a theme
ThemeSet ts = ThemeSet.LoadDefaults();
Theme theme = ts["InspiredGitHub"];  // github syntax highlighting theme

// highlight source code to html
string sourceCode = @"using ColorfulCode;

namespace HelloWorld {
    class Program {
        static Main(string[] args) {
            Console.WriteLine(""Hello World"");
        }
    }
}
";
string html = syntax.HighlightToHtml(sourceCode, theme);
Console.WriteLine(html);

Run the code, you can see the highlighted html on your console:

<pre style="background-color:#ffffff;">
<span style="font-weight:bold;color:#a71d5d;">using </span><span style="color:#323232;">ColorfulCode;
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">namespace </span><span style="color:#323232;">HelloWorld {
</span><span style="color:#323232;">    </span><span style="font-weight:bold;color:#a71d5d;">class </span><span style="color:#0086b3;">Program </span><span style="color:#323232;">{
</span><span style="color:#323232;">        </span><span style="font-weight:bold;color:#a71d5d;">static </span><span style="font-weight:bold;color:#795da3;">Main</span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">string</span><span style="color:#323232;">[] args) {
</span><span style="color:#323232;">            Console.WriteLine(</span><span style="color:#183691;">&quot;Hello World&quot;</span><span style="color:#323232;">);
</span><span style="color:#323232;">        }
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">}
</span></pre>

Supported Languages

Default SyntaxSet:

Plain Text, ASP, HTML (ASP), ActionScript, AppleScript, Batch File, NAnt Build File, C#, C++, C, CSS, Clojure, D, Diff, Erlang, HTML (Erlang), Go, Graphviz (DOT), Groovy, HTML, Haskell, Literate Haskell, Java Server Page (JSP), Java, JavaDoc, Java Properties, JSON, JavaScript, Regular Expressions (Javascript), BibTeX, LaTeX Log, LaTeX, TeX, Lisp, Lua, Make Output, Makefile, Markdown, MultiMarkdown, MATLAB, OCaml, OCamllex, OCamlyacc, camlp4, Objective-C++, Objective-C, PHP Source, PHP, Pascal, Perl, Python, Regular Expressions (Python), R Console, R, Rd (R Documentation), HTML (Rails), JavaScript (Rails), Ruby Haml, Ruby on Rails, SQL (Rails), Regular Expression, reStructuredText, Ruby, Cargo Build Results, Rust, SQL, Scala, Bourne Again Shell (bash), Shell-Unix-Generic, commands-builtin-shell-bash, HTML (Tcl), Tcl, Textile, XML, YAML

Supported Themes

Default ThemeSet:

  • InspiredGitHub
  • Solarized (dark)
  • Solarized (light)
  • base16-eighties.dark
  • base16-mocha.dark
  • base16-ocean.dark
  • base16-ocean.light

Features / Goals

  • Support highlight code to HTML
  • Syntax: Include more syntax definitions of commonly used language into default syntax set
  • Syntax: Support custom syntax definitions
  • Theme: Support custom theme definitions
  • Support highlight code for terminal

License

ColorfulCode is licensed under the Apache-2.0 license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.