Markdown
Markdown
Write Markdown in SunSed
SunSed comes with 2 functions that transform markdown to HTML. markdown:original_markdown_to_html(), converts traditional markdown to HTMl, while markdown:to_html converts extra markdown flavors to HTML.
markdown:to_html("# hi2")
#=> "<h1>hi2</h1>\n"
markdown:to_html("*hi*")
#=> "<p><em>hi</em></p>\n"
Add Markdown Function to Templates
The cleanest way to add markdown functions to your app is to create a custom template that runs the content through markdown transformation functions.
SECTION function -> template:markdown {
/*
purpose ~> Converts Markdown to HTML
tags ~>
access ~> private
stable? ~> No
schedule ~>
examples ~>
*/
template:markdown = ƒ($content = "", $options){
$content = markdown:to_html($content)
RETURN template:main($content, $options)
}
}
fter creating the template, you need to place the following code at the top (right after the SunSed open tag) of the pages you want to convert markdown to HTML. You can learn more about creating and using templates [/manual/ui/template].
<?
# template => markdown
?>
### My Header
My paragraph and the [link](/link)
