normalizeBody trims a trailing run of whitespace/newlines and ensures the body ends with exactly one trailing "\n". An empty body becomes "\n".
(body string)
| 85 | // normalizeBody trims a trailing run of whitespace/newlines and ensures the |
| 86 | // body ends with exactly one trailing "\n". An empty body becomes "\n". |
| 87 | func normalizeBody(body string) string { |
| 88 | trimmed := strings.TrimRight(body, "\n") |
| 89 | return trimmed + "\n" |
| 90 | } |
| 91 | |
| 92 | // toString coerces a scalar frontmatter value to string. Values originate as |
| 93 | // strings in practice; non-strings are rendered defensively. |