Markdown.ColorCode 2.2.1

dotnet add package Markdown.ColorCode --version 2.2.1
NuGet\Install-Package Markdown.ColorCode -Version 2.2.1
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="Markdown.ColorCode" Version="2.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Markdown.ColorCode --version 2.2.1
#r "nuget: Markdown.ColorCode, 2.2.1"
#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.
// Install Markdown.ColorCode as a Cake Addin
#addin nuget:?package=Markdown.ColorCode&version=2.2.1

// Install Markdown.ColorCode as a Cake Tool
#tool nuget:?package=Markdown.ColorCode&version=2.2.1

Markdown.ColorCode

Build Coverage

Version Downloads

Contributor Covenant Contributors Commits

Forks Stargazers Issues MIT License

LinkedIn

About The Project

An extension for Markdig that adds syntax highlighting to code through the power of ColorCode.

Demonstration

Before

using Foo.Bar.Baz;

namespace Foo.Api;

public interface FooService {
    /// <summary>
    ///     Gets a new Foo!
    /// </summary>
    /// <returns>A new Foo</returns>
    public void GetFoo() {
        return new Foo();
    }
}

After

using Foo.Bar.Baz;

namespace Foo.Api;

public interface FooService {
    /// <summary>
    ///     Gets a new Foo!
    /// </summary>
    /// <returns>A new Foo</returns>
    public void GetFoo() {
        return new Foo();
    }
}

Installation

Package Manager

Install-Package Markdown.ColorCode -Version 2.2.1

.NET CLI

dotnet add package Markdown.ColorCode --version 2.2.1

Usage

To use this extension with Markdig, simply install the Markdown.ColorCode package use the ColorCode extension:

var pipeline = new MarkdownPipelineBuilder()
    .UseAdvancedExtensions()
    .UseColorCode()
    .Build();

var colorizedHtml = Markdig.Markdown.ToHtml(someMarkdown, pipeline);

Several optional configuration options are also at your disposal:

var pipeline = new MarkdownPipelineBuilder()
    .UseAdvancedExtensions()
    .UseColorCode(
        HtmlFormatterType.Style, // use style-based colorization (default)
        myCustomStyleDictionary, // use a custom colorization style dictionary
        myAdditionalLanguages, // augment the built-in language support
        myCustomLanguageId // set a default language ID to fall back to
    )
    .Build();

var colorizedHtml = Markdig.Markdown.ToHtml(someMarkdown, pipeline);

Improved C# Syntax Highlighting

For an improved experience with C# code blocks, consider using the Markdown.ColorCode.CSharpToColoredHtml package. This package provides a more robust syntax highlighting experience for C# code blocks by leveraging CSharpToColouredHtml.Core.

var pipeline = new MarkdownPipelineBuilder()
    .UseAdvancedExtensions()
    .UseColorCodeWithCSharpToColoredHtml(
        HtmlFormatterType.Style, // use style-based colorization (default)
        myCustomStyleDictionary, // use a custom colorization style dictionary
        myHtmlEmitterSettings, // configures CSharpToColouredHtml's HTML emitter
        myAdditionalLanguages, // augment the built-in language support
        myCustomLanguageId // set a default language ID to fall back to
    )
    .Build();

var colorizedHtml = Markdig.Markdown.ToHtml(someMarkdown, pipeline);

[!CAUTION] The CsharpToColouredHTML package introduces dependencies which will not work well with Blazor WebAssembly projects. Either generate the HTML on the server side and send it to the client or use the base Markdown.ColorCode package if you are working with Blazor WebAssembly. See https://github.com/dotnet/aspnetcore/issues/27373 and https://github.com/dotnet/aspnetcore/issues/26724 for more details on the problem.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. For detailed contributing guidelines, please see CONTRIBUTING.md.

License

Distributed under the MIT License License. See LICENSE for more information.

Contact

@wbaldoumas

Project Link: https://github.com/wbaldoumas/markdown-colorcode

Acknowledgements

This README was adapted from https://github.com/othneildrew/Best-README-Template.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Markdown.ColorCode:

Package Downloads
Markdown.ColorCode.CSharpToColoredHtml

An extension for Markdig that adds syntax highlighting to code through the power of ColorCode, boosted with the CsharpToColouredHTML.Core package.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.1 2,213 2/18/2024
2.2.0 318 2/13/2024
2.2.0-preview-5 75 2/13/2024
2.2.0-preview-4 64 2/12/2024
2.1.0 7,481 11/16/2023
2.0.0 4,315 9/3/2023
2.0.0-preview-1 115 8/23/2023
1.1.2 2,105 8/18/2023
1.1.1 1,689 8/1/2023
1.1.0 130 8/1/2023
1.1.0-preview-1 120 7/30/2023
1.0.4 5,420 5/26/2023
1.0.4-preview-2 108 5/25/2023
1.0.3 3,364 3/12/2023
1.0.2 7,563 12/10/2022
1.0.1 11,864 3/19/2022
1.0.0 1,030 1/20/2022
0.1.0 557 1/15/2022