1/*
2Package html implements HTML renderer of parsed markdown document.
3
4Configuring and customizing a renderer
5
6A renderer can be configured with multiple options:
7
8 import "github.com/gomarkdown/markdown/html"
9
10 flags := html.CommonFlags | html.CompletePage | html.HrefTargetBlank
11 opts := html.RenderOptions{
12 TItle: "A custom title",
13 Flags: flags,
14 }
15 renderer := html.NewRenderer(opts)
16
17You can also re-use most of the logic and customize rendering of selected nodes
18by providing node render hook.
19This is most useful for rendering nodes that allow for design choices, like
20links or code blocks.
21
22 import (
23 "github.com/gomarkdown/markdown/html"
24 "github.com/gomarkdown/markdown/ast"
25 )
26
27 // a very dummy render hook that will output "code_replacements" instead of
28 // <code>${content}</code> emitted by html.Renderer
29 func renderHookCodeBlock(w io.Writer, node *ast.Node, entering bool) (ast.WalkStatus, bool) {
30 _, ok := node.Data.(*ast.CodeBlockData)
31 if !ok {
32 return ast.GoToNext, false
33 }
34 io.WriteString(w, "code_replacement")
35 return ast.GoToNext, true
36 }
37
38 opts := html.RendererOptions{
39 RenderNodeHook: renderHookCodeBlock,
40 }
41 renderer := html.NewRenderer(opts)
42*/
43package html