From 1f605d43ca4730b0387cc439a9de493d94531703 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 27 Sep 2017 10:46:32 +0200 Subject: [PATCH] Fix leading characters being stripped from example sections in YAML `strings.Trim()` strips any character listed in the `cutset` argument, so any example section having `E`, `x`, `a`, `m`, `p`, `l`, `e`, or `s` in the first word, had these characters missing in the generated YAML. Also trim superfluent whitespace characters to consistently use `|-` ("strip") as block chomping indicator (see http://www.yaml.org/spec/1.2/spec.html#id2794534) Signed-off-by: Sebastiaan van Stijn --- docs/yaml/yaml.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/yaml/yaml.go b/docs/yaml/yaml.go index 2dbe406bdb..42c46ec2f0 100644 --- a/docs/yaml/yaml.go +++ b/docs/yaml/yaml.go @@ -220,10 +220,10 @@ func parseMDContent(mdString string) (description string, examples string) { parsedContent := strings.Split(mdString, "\n## ") for _, s := range parsedContent { if strings.Index(s, "Description") == 0 { - description = strings.Trim(s, "Description\n") + description = strings.TrimSpace(strings.TrimPrefix(s, "Description")) } if strings.Index(s, "Examples") == 0 { - examples = strings.Trim(s, "Examples\n") + examples = strings.TrimSpace(strings.TrimPrefix(s, "Examples")) } } return