From ae6bf22a0e884c8b7aa2178e38b42cf6d4c8464e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?n=CE=B9c=D0=BDola=D1=95=20w=CE=B9lde?= Date: Sun, 24 Apr 2022 06:51:31 +0000 Subject: [PATCH] Fix commentsSection (fix #3) --- cmd/cook-docs/testdata/My Test Recipe.cook | 7 ++++--- pkg/document/template.go | 6 +----- vendor/modules.txt | 10 ---------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/cmd/cook-docs/testdata/My Test Recipe.cook b/cmd/cook-docs/testdata/My Test Recipe.cook index 6228cd2..1bca763 100644 --- a/cmd/cook-docs/testdata/My Test Recipe.cook +++ b/cmd/cook-docs/testdata/My Test Recipe.cook @@ -1,11 +1,12 @@ >> servings: 6 >> source: https://www.somewebsite.com/pizza-balls +-- Header comment -Make 6 pizza balls using @tipo zero flour{820%g}, @water{533%ml}, @salt{24.6%g} and @fresh yeast{1.6%g}. Put in a #fridge for ~{2%days}. +Make 6 pizza balls using @tipo zero flour{820%g}, @water{533%ml}, @salt{24.6%g} and @fresh yeast{1.6%g}. Put in a #fridge for ~{2%days}. -- step 1 comment -Set #oven to max temperature and heat #pizza stone{} for about ~{40%minutes}. +Set #oven to max temperature and heat #pizza stone{} for about ~{40%minutes}. -- step 2 comment -Make some tomato sauce with @chopped tomato{3%cans} and @garlic{3%cloves} and @dried oregano{3%tbsp}. Put on a #pan and leave for ~{15%minutes} occasionally stirring. +Make some tomato sauce with @chopped tomato{3%cans} and @garlic{3%cloves} and @dried oregano{3%tbsp}. [- step 3 comment -] Put on a #pan and leave for ~{15%minutes} occasionally stirring. Make pizzas putting some tomato sauce with #spoon on top of flattened dough. Add @fresh basil{18%leaves}, @parma ham{3%packs} and @mozzarella{3%packs}. diff --git a/pkg/document/template.go b/pkg/document/template.go index 6895add..53503ba 100644 --- a/pkg/document/template.go +++ b/pkg/document/template.go @@ -180,18 +180,14 @@ func getCommentsTemplate() string { templateBuilder.WriteString("{{ end }}") templateBuilder.WriteString(`{{ define "cook.comments" }}`) - //templateBuilder.WriteString("{{ range .Steps }}{{- range .Comments }}\n- {{.}}{{- end }}{{- end }}") + templateBuilder.WriteString("{{ range .Steps }}{{ range .Comments }}\n- {{.}}{{- end }}{{- end }}") templateBuilder.WriteString("{{ end }}") templateBuilder.WriteString(`{{ define "cook.commentsSection" }}`) - templateBuilder.WriteString("{{ range .Steps }}") - templateBuilder.WriteString("{{ if .Comments }}") templateBuilder.WriteString(`{{ template "cook.commentsHeader" . }}`) templateBuilder.WriteString("\n") templateBuilder.WriteString(`{{ template "cook.comments" . }}`) templateBuilder.WriteString("{{ end }}") - templateBuilder.WriteString("{{ end }}") - templateBuilder.WriteString("{{ end }}") return templateBuilder.String() } diff --git a/vendor/modules.txt b/vendor/modules.txt index dc5d062..aa1c766 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,10 +7,6 @@ github.com/Masterminds/semver/v3 # github.com/Masterminds/sprig/v3 v3.2.2 ## explicit; go 1.13 github.com/Masterminds/sprig/v3 -# github.com/alecthomas/gometalinter v3.0.0+incompatible -## explicit -# github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 -## explicit; go 1.15 # github.com/aquilax/cooklang-go v0.1.6 ## explicit; go 1.17 github.com/aquilax/cooklang-go @@ -20,8 +16,6 @@ github.com/davecgh/go-spew/spew # github.com/fsnotify/fsnotify v1.5.1 ## explicit; go 1.13 github.com/fsnotify/fsnotify -# github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 -## explicit; go 1.13 # github.com/google/uuid v1.1.2 ## explicit github.com/google/uuid @@ -60,8 +54,6 @@ github.com/mitchellh/mapstructure # github.com/mitchellh/reflectwalk v1.0.0 ## explicit github.com/mitchellh/reflectwalk -# github.com/nicksnyder/go-i18n v1.10.1 -## explicit # github.com/pelletier/go-toml v1.9.5 ## explicit; go 1.12 github.com/pelletier/go-toml @@ -126,8 +118,6 @@ golang.org/x/text/unicode/norm ## explicit; go 1.17 # golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f ## explicit; go 1.11 -# gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20191105091915-95d230a53780 -## explicit # gopkg.in/ini.v1 v1.66.4 ## explicit gopkg.in/ini.v1