April 13, 2016 by Anuraj
ASP.NET MVC ASP.NET Core ASP.NET5 Markdown TagHelper CodeProject
Markdown is a lightweight markup language with plain text formatting syntax designed so that it can be converted to HTML and many other formats using a tool by the same name. Markdown is often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor. Over the past few years, StackOverflow uses Markdown for formatting in the questions. This post is about creating a tag helper to render markdown in your view. I am using Markdown package from nuget to render the content. Here is my project.json file, which is using markdown package.
Here is the code for tag helper
Add the TagHelper inside _ViewImports.cshtml.
And you can use the Tag helper in the code like this. This tag helper supports both text and source properties, which helps users to display markdown text and model properties. In the view you can use like this, with markdown text.
And you can bind model properties as well, like this.
which will render like this.
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub