multipart markdown documents
This commit is contained in:
parent
bf2a836cdc
commit
26418217ac
@ -11,4 +11,10 @@ Template: mitBild.html
|
||||
|
||||
# Leistungen
|
||||
|
||||
Hier stehen die ***Referenzen***, dsfdfsadfasdf.
|
||||
Hier stehen die ***Referenzen***, dsfdfsadfasdf.
|
||||
|
||||
---
|
||||
|
||||
### Hinweis
|
||||
|
||||
Das hier ist der `BodyPart.[1]`
|
@ -9,7 +9,11 @@
|
||||
<img src="{{ Data.bild }}" id="dataImg">
|
||||
{{/if}}
|
||||
|
||||
{{{ Body }}}
|
||||
{{{ BodyParts.[0] }}}
|
||||
|
||||
{{#if BodyParts.[1] }}
|
||||
<div class="info">{{{ BodyParts.[1] }}}</div>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
|
||||
|
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user