diff options
author | crasm <crasm@git.1.email.vczf.io> | 2016-12-20 16:54:52 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-13 19:19:03 +0300 |
commit | ede452d34ef82a2d6949bf0c5a4584caf3ae03bc (patch) | |
tree | d387ff6749adc0ef10a5dbb1ba9a22d3642f8be8 /parser/page.go | |
parent | 62efcdfed443239711910592e2d35cd955caea84 (diff) |
parser: Accept JSON frontmatter without leading "{\n"
Accept JSON frontmatter without leading "{\n" so that one line
frontmatters such as `{"param":"paramvalue"}` no longer silently render
empty html.
Diffstat (limited to 'parser/page.go')
-rw-r--r-- | parser/page.go | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/parser/page.go b/parser/page.go index a0679289c..9639dd7a4 100644 --- a/parser/page.go +++ b/parser/page.go @@ -283,19 +283,12 @@ func isFrontMatterDelim(data []byte) bool { } func determineDelims(firstLine []byte) (left, right []byte) { - switch len(firstLine) { - case 5: - fallthrough - case 4: - if firstLine[0] == YAMLLead[0] { - return []byte(YAMLDelim), []byte(YAMLDelim) - } + switch firstLine[0] { + case YAMLLead[0]: + return []byte(YAMLDelim), []byte(YAMLDelim) + case TOMLLead[0]: return []byte(TOMLDelim), []byte(TOMLDelim) - case 3: - fallthrough - case 2: - fallthrough - case 1: + case JSONLead[0]: return []byte(JSONLead), []byte("}") default: panic(fmt.Sprintf("Unable to determine delims from %q", firstLine)) |