mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-20 22:52:58 -05:00
templates: Fix front matter closing fence search
This makes it choose first matching closing fence instead of last one, which could appear in document body.
This commit is contained in:
parent
efc0cc5e85
commit
a2dae1d43f
2 changed files with 12 additions and 0 deletions
|
@ -56,6 +56,7 @@ func extractFrontMatter(input string) (map[string]interface{}, string, error) {
|
||||||
if index >= 0 {
|
if index >= 0 {
|
||||||
fmEndFenceStart = index
|
fmEndFenceStart = index
|
||||||
fmEndFence = fence
|
fmEndFence = fence
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fmEndFenceStart < 0 {
|
if fmEndFenceStart < 0 {
|
||||||
|
|
|
@ -316,6 +316,17 @@ title: Welcome
|
||||||
expect: `Welcome`,
|
expect: `Welcome`,
|
||||||
body: "\n### Test",
|
body: "\n### Test",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// yaml with non-fence '...' line after closing fence (i.e. first matching closing fence should be used)
|
||||||
|
input: `---
|
||||||
|
title: Welcome
|
||||||
|
---
|
||||||
|
### Test
|
||||||
|
...
|
||||||
|
yeah`,
|
||||||
|
expect: `Welcome`,
|
||||||
|
body: "\n### Test\n...\nyeah",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// toml
|
// toml
|
||||||
input: `+++
|
input: `+++
|
||||||
|
|
Loading…
Add table
Reference in a new issue