changeset 15:ebecd141e9d3

Fix crash when there is no YAML
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 25 Jun 2020 21:16:19 +0200
parents 78282df000f2
children c515a9fa8bd5
files test.md wdown.go
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test.md	Mon Jun 22 07:55:14 2020 +0200
+++ b/test.md	Thu Jun 25 21:16:19 2020 +0200
@@ -53,6 +53,8 @@
 
 ## TODO
 Some things need doing
+ - [x] Fix bug where there's a nil error when there is no yaml in .md file
+ - [ ] Fix bug where wdown doesn't work without a template
  - [x] Build the simplest possible markdown commandline utility
  - [x] Add command-line argument parsing
  - [x] Allow template file as an input
--- a/wdown.go	Mon Jun 22 07:55:14 2020 +0200
+++ b/wdown.go	Thu Jun 25 21:16:19 2020 +0200
@@ -66,6 +66,9 @@
 
 	if useTemplate {
 		templateVars := meta.Get(parserContext)
+		if templateVars == nil {
+			templateVars = map[string]interface{}{}
+		}
 		templateVars["content"] = htmlContent.String()
 
 		err := tmpl.FRender(os.Stdout, templateVars)