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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2017-09-27 10:46:32 +02:00
parent da82dcb1db
commit 1f605d43ca
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 2 additions and 2 deletions

View File

@ -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