multipart markdown documents
This commit is contained in:
11
main.go
11
main.go
@@ -355,7 +355,7 @@ func processContent(conf *PathConfigTree) {
|
||||
|
||||
newConfig := new(PathConfig)
|
||||
|
||||
regex := regexp.MustCompile("(?sm)^---(.*)^---")
|
||||
regex := regexp.MustCompile("(?s)^---(.*?)\\r?\\n\\r?---\\r?\\n\\r?")
|
||||
yamlData := regex.Find(input)
|
||||
if string(yamlData) != "" {
|
||||
log.Debugf("found yaml header in '%s', merging config", inFile)
|
||||
@@ -417,6 +417,14 @@ func processContent(conf *PathConfigTree) {
|
||||
//html := blackfriday.Run(input, blackfriday.WithRenderer(bfchroma.NewRenderer()))
|
||||
html := blackfriday.Run(input)
|
||||
|
||||
// use --- for splitting document in markdown parts
|
||||
regex := regexp.MustCompile("\\r?\\n\\r?---\\r?\\n\\r?")
|
||||
inputParts := regex.Split(string(input), -1)
|
||||
htmlParts := make([]string, 0)
|
||||
for _, iPart := range inputParts {
|
||||
htmlParts = append(htmlParts, string(blackfriday.Run([]byte(iPart))))
|
||||
}
|
||||
|
||||
log.Debugf("rendering template '%s' for '%s'", *newConfig.Template, outFile)
|
||||
templateFile := *inDir + "/templates/" + *newConfig.Template
|
||||
template := templateCache[templateFile]
|
||||
@@ -449,6 +457,7 @@ func processContent(conf *PathConfigTree) {
|
||||
ctx["NavSlice"] = navSlice
|
||||
ctx["NavActive"] = navActive
|
||||
ctx["Body"] = string(html)
|
||||
ctx["BodyParts"] = htmlParts
|
||||
|
||||
result, err := template.Exec(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user