diff options
author | Cameron Moore <[email protected]> | 2016-12-26 15:23:20 -0600 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-03-11 17:52:25 +0100 |
commit | f039e3be9e4a11808508c8cd3043b340deea040f (patch) | |
tree | df3e709fc6321fd2a3e1d23efa2c3512d8ed4a94 /commands/import_jekyll.go | |
parent | ddc8cc0082965143a650052a9aa538bac9133481 (diff) | |
download | hugo-f039e3be9e4a11808508c8cd3043b340deea040f.tar.gz hugo-f039e3be9e4a11808508c8cd3043b340deea040f.zip |
parser: Refactor frontmatter parser and add tests
Lots of cleanups here:
- Refactor InterfaceToConfig and InterfaceToFrontMatter to use io.Writer.
- Simplify InterfaceToFrontMatter by wrapping InterfaceToConfig.
- Export FrontmatterType since we return it in DetectFrontMatter.
- Refactor removeTOMLIdentifier to avoid blindly replacing "+++".
- Update HandleJSONMetaData to return an empty map on nil input.
- Updates vendored goorgeous package and test for org-mode frontmatter.
- Add tests and godoc comments.
Coverage for parser package increased from 45.2% to 85.2%.
Diffstat (limited to 'commands/import_jekyll.go')
-rw-r--r-- | commands/import_jekyll.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go index 151fffa8a..c33b68f2e 100644 --- a/commands/import_jekyll.go +++ b/commands/import_jekyll.go @@ -251,17 +251,13 @@ func createConfigFromJekyll(fs afero.Fs, inpath string, kind string, jekyllConfi } kind = parser.FormatSanitize(kind) - by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind)) + var buf bytes.Buffer + err = parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind), &buf) if err != nil { return err } - err = helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), bytes.NewReader(by), fs) - if err != nil { - return - } - - return nil + return helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), &buf, fs) } func copyFile(source string, dest string) error { |