Imports System.Runtime.CompilerServices
Imports MarkdownDeep
Imports System.Web
Imports System.Web.Mvc
'http://blog.dantup.com/2011/03/an-asp-net-mvc-htmlhelper-extension-method-for-markdown-using-markdownsharp
Public Module MarkdownHelper
'''
''' Transforms a string of Markdown into HTML.
'''
''' The Markdown that should be transformed.
''' The HTML representation of the supplied Markdown.
Public Function Markdown(ByVal text As String,
Optional ByVal bolSafeMode As Boolean = True) As IHtmlString
Dim md = New Markdown With {
.ExtraMode = True,
.SafeMode = bolSafeMode,
.NewWindowForExternalLinks = True
}
Dim html As String = md.Transform(text)
Return New MvcHtmlString(html)
End Function
'''
''' Transforms a string of Markdown into Plain Text
'''
'''
'''
'''
Public Function MarkdownText(text As String) As String
Dim str As String = Nothing
Try
Dim md = New Markdown()
md.SummaryLength = -1
str = md.Transform(text)
Catch ex As Exception
End Try
Return str
End Function
'''
''' Transforms a string of Markdown into HTML.
'''
''' HtmlHelper - Not used, but required to make this an extension method.
''' The Markdown that should be transformed.
''' The HTML representation of the supplied Markdown.
_
Public Function Markdown(helper As HtmlHelper, text As String) As MvcHtmlString
Return Markdown(text)
End Function
End Module