From 368bd244aed0709c8b1bb05464d44f4d0cca07a4 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Thu, 21 Mar 2019 07:55:32 -0700 Subject: vendor some dependencies --- internal/front/LICENSE | 19 +++++++++++++++++++ internal/front/front.go | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 internal/front/LICENSE create mode 100644 internal/front/front.go (limited to 'internal/front') diff --git a/internal/front/LICENSE b/internal/front/LICENSE new file mode 100644 index 0000000..e8152bb --- /dev/null +++ b/internal/front/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/internal/front/front.go b/internal/front/front.go new file mode 100644 index 0000000..b2c7f0e --- /dev/null +++ b/internal/front/front.go @@ -0,0 +1,24 @@ +// Package front provides YAML frontmatter unmarshalling. +package front + +import ( + "bytes" + + "gopkg.in/yaml.v2" +) + +// Delimiter. +var delim = []byte("---") + +// Unmarshal parses YAML frontmatter and returns the content. When no +// frontmatter delimiters are present the original content is returned. +func Unmarshal(b []byte, v interface{}) (content []byte, err error) { + if !bytes.HasPrefix(b, delim) { + return b, nil + } + + parts := bytes.SplitN(b, delim, 3) + content = parts[2] + err = yaml.Unmarshal(parts[1], v) + return +} -- cgit v1.2.3