multipart markdown documents
This commit is contained in:
@@ -11,4 +11,10 @@ Template: mitBild.html
|
|||||||
|
|
||||||
# Leistungen
|
# 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">
|
<img src="{{ Data.bild }}" id="dataImg">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{{ Body }}}
|
{{{ BodyParts.[0] }}}
|
||||||
|
|
||||||
|
{{#if BodyParts.[1] }}
|
||||||
|
<div class="info">{{{ BodyParts.[1] }}}</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
11
main.go
11
main.go
@@ -355,7 +355,7 @@ func processContent(conf *PathConfigTree) {
|
|||||||
|
|
||||||
newConfig := new(PathConfig)
|
newConfig := new(PathConfig)
|
||||||
|
|
||||||
regex := regexp.MustCompile("(?sm)^---(.*)^---")
|
regex := regexp.MustCompile("(?s)^---(.*?)\\r?\\n\\r?---\\r?\\n\\r?")
|
||||||
yamlData := regex.Find(input)
|
yamlData := regex.Find(input)
|
||||||
if string(yamlData) != "" {
|
if string(yamlData) != "" {
|
||||||
log.Debugf("found yaml header in '%s', merging config", inFile)
|
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, blackfriday.WithRenderer(bfchroma.NewRenderer()))
|
||||||
html := blackfriday.Run(input)
|
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)
|
log.Debugf("rendering template '%s' for '%s'", *newConfig.Template, outFile)
|
||||||
templateFile := *inDir + "/templates/" + *newConfig.Template
|
templateFile := *inDir + "/templates/" + *newConfig.Template
|
||||||
template := templateCache[templateFile]
|
template := templateCache[templateFile]
|
||||||
@@ -449,6 +457,7 @@ func processContent(conf *PathConfigTree) {
|
|||||||
ctx["NavSlice"] = navSlice
|
ctx["NavSlice"] = navSlice
|
||||||
ctx["NavActive"] = navActive
|
ctx["NavActive"] = navActive
|
||||||
ctx["Body"] = string(html)
|
ctx["Body"] = string(html)
|
||||||
|
ctx["BodyParts"] = htmlParts
|
||||||
|
|
||||||
result, err := template.Exec(ctx)
|
result, err := template.Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user