-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
36 lines (33 loc) · 1.21 KB
/
parser_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"strings"
"testing"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
)
func TestParserHeading(t *testing.T) {
app := App{
SiteTemplate: "site.html",
SrcDir: "src",
DistDir: "dist",
Layouts: make(map[string]string),
Pages: make([]Page, 0),
IgnoreFolders: make(map[string]bool),
IgnoreFiles: make(map[string]bool),
ThemeConfig: ThemeConfig{},
}
md := []byte("# Heading One\n## Heading Two\n### Heading Three\n#### Heading Four\n##### Heading Five\n###### Heading Six")
// render the markdown file
opts := html.RendererOptions{
Flags: html.FlagsNone,
RenderNodeHook: app.renderHook,
}
renderer := html.NewRenderer(opts)
output := string(markdown.ToHTML(md, nil, renderer))
output = strings.ReplaceAll(output, "\n", "")
output = strings.ReplaceAll(output, "\t", "")
output = strings.ReplaceAll(output, " ", "")
if output != "<h1>HeadingOne</h1><h2>HeadingTwo</h2><h3>HeadingThree</h3><h4>HeadingFour</h4><h5>HeadingFive</h5><h6>HeadingSix</h6>" {
t.Errorf("Expected: %s, got: %s", "<h1>Heading One</h1><h2>Heading Two</h2><h3>Heading Three</h3><h4>Heading Four</h4><h5>Heading Five</h5><h6>Heading Six</h6>", output)
}
}