Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

wbaldoumas/markdown-colorcode

BuildCoverage

VersionDownloads

Contributor CovenantContributorsCommits

ForksStargazersIssuesMIT License

LinkedIn

About The Project

An extension forMarkdig that adds syntax highlighting to code through the power ofColorCode.

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

usingFoo.Bar.Baz;namespaceFoo.Api;publicinterfaceFooService{/// <summary>///     Gets a new Foo!/// </summary>/// <returns>A new Foo</returns>publicvoidGetFoo(){returnnewFoo();}}

Installation

Package Manager

Install-Package Markdown.ColorCode -Version 3.0.1

.NET CLI

dotnet add package Markdown.ColorCode --version 3.0.1

Usage

To use this extension withMarkdig, simply install theMarkdown.ColorCode package use the ColorCode extension:

varpipeline=newMarkdownPipelineBuilder().UseAdvancedExtensions().UseColorCode().Build();varcolorizedHtml=Markdig.Markdown.ToHtml(someMarkdown,pipeline);

Several optional configuration options are also at your disposal:

varpipeline=newMarkdownPipelineBuilder().UseAdvancedExtensions().UseColorCode(HtmlFormatterType.Style,// use style-based colorization (default)myCustomStyleDictionary,// use a custom colorization style dictionarymyAdditionalLanguages,// augment the built-in language supportmyCustomLanguageId// set a default language ID to fall back to).Build();varcolorizedHtml=Markdig.Markdown.ToHtml(someMarkdown,pipeline);

Improved C# Syntax Highlighting

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

varpipeline=newMarkdownPipelineBuilder().UseAdvancedExtensions().UseColorCodeWithCSharpToColoredHtml(HtmlFormatterType.Style,// use style-based colorization (default)myCustomStyleDictionary,// use a custom colorization style dictionarymyHtmlEmitterSettings,// configures CSharpToColouredHtml's HTML emittermyAdditionalLanguages,// augment the built-in language supportmyCustomLanguageId// set a default language ID to fall back to).Build();varcolorizedHtml=Markdig.Markdown.ToHtml(someMarkdown,pipeline);

Note

TheCsharpToColouredHTML 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 baseMarkdown.ColorCode package if you are working with Blazor WebAssembly. Seedotnet/aspnetcore#27373 anddotnet/aspnetcore#26724 for more details on the problem.

Roadmap

See theopen 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 aregreatly appreciated. For detailed contributing guidelines, please seeCONTRIBUTING.md.

License

Distributed under theMIT License License. SeeLICENSE for more information.

Contact

@wbaldoumas

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

Acknowledgements

ThisREADME was adapted fromhttps://github.com/othneildrew/Best-README-Template.


[8]ページ先頭

©2009-2025 Movatter.jp