Markdown rendering
Render a safe subset of markdown into app elements, with live components in fences.
The
markdown
package renders Markdown source into a tree of
app.UI
elements. It is a subset renderer: it supports the constructs listed on this page and treats everything else as plain text.
ยง1 RenderMarkdown
func
RenderMarkdown
(
source
string
,
style
Style
)
[
]
app
.
UI
RenderMarkdown
parses
source
and returns a slice of
app.UI
block elements, one per top-level Markdown block (paragraph, heading, list, blockquote, code block, and so on).
If
source
is empty or contains only whitespace,
RenderMarkdown
returns
nil
.
Minimal usage:
package
main
import
(
"github.com/Toms223/WebGo/markdown"
"github.com/Toms223/WebGo/app"
)
func
Body
(
source
string
)
[
]
app
.
UI
{
return
markdown
.
RenderMarkdown
(
source
,
markdown
.
Style
{
Heading
:
"heading"
,
Subheading
:
"subheading"
,
}
)
}
A paragraph rendered through it:
A paragraph with *emphasis* and **strong** text.
A paragraph with emphasis and strong text.