- Notifications
You must be signed in to change notification settings - Fork6
An extension for Markdig that adds syntax highlighting to code through the power of ColorCode-Universal.
License
wbaldoumas/markdown-colorcode
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An extension forMarkdig that adds syntax highlighting to code through the power ofColorCode.
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(); }}
usingFoo.Bar.Baz;namespaceFoo.Api;publicinterfaceFooService{/// <summary>/// Gets a new Foo!/// </summary>/// <returns>A new Foo</returns>publicvoidGetFoo(){returnnewFoo();}}
Install-Package Markdown.ColorCode -Version 3.0.1
dotnet add package Markdown.ColorCode --version 3.0.1
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);
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.
See theopen issues for a list of proposed features (and known issues).
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.
Distributed under theMIT License
License. SeeLICENSE
for more information.
Project Link:https://github.com/wbaldoumas/markdown-colorcode
ThisREADME
was adapted fromhttps://github.com/othneildrew/Best-README-Template.
About
An extension for Markdig that adds syntax highlighting to code through the power of ColorCode-Universal.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.