Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
EngincanV committed Jan 5, 2023
1 parent 774cec8 commit 1b157ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion demo/LineHighlightDemo/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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()");
Expand Down

0 comments on commit 1b157ed

Please sign in to comment.