From 1b157ed25bc9325e1bd059fcc441a7d94a3e3459 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Thu, 5 Jan 2023 10:00:04 +0300 Subject: [PATCH] Update README.md --- README.md | 2 ++ demo/LineHighlightDemo/Views/Home/Index.cshtml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a57b12c..58ad3d1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ Let's assume you have markdown content and want to highlight the 3rd line. You c \``` ``` +> You can specify more than one line to highlight and also specify line intervals to highlight. For example, `csharp {3-5, 7}` with such use, the 3rd, 4th, 5th and 7th lines will be highlighted. + To render this markdown as HTML, you can use `Markdown.ToHtml` method. This method basically gets two parameters: the first one is the markdown content and the second one is a pipeline, which can be considered custom steps that we want to apply while rendering the content as HTML. You need to add [HighlightedCodeBlockExtension](https://github.com/EngincanV/Markdig.Extensions.LineHighlight/blob/main/src/Markdig.Extensions.LineHighlight/Markdown/Extensions/HighlightedCodeBlockExtension.cs#L8) to this pipeline to the benefit of code-highlighting. For this purpose, you can use the `UseHighlightedCodeBlocks` method while building the pipeline and passing it through the `Markdown.ToHtml` method as below: diff --git a/demo/LineHighlightDemo/Views/Home/Index.cshtml b/demo/LineHighlightDemo/Views/Home/Index.cshtml index c0ed185..a61a2e2 100644 --- a/demo/LineHighlightDemo/Views/Home/Index.cshtml +++ b/demo/LineHighlightDemo/Views/Home/Index.cshtml @@ -6,7 +6,7 @@ //Markdown Example var text = new StringBuilder(); - text.AppendLine("```csharp {3}"); + text.AppendLine("```csharp {3-5, 7}"); text.AppendLine("public class HelloWorld"); text.AppendLine("{"); text.AppendLine("\tpublic void ShowMessage()");