Repos / s4g / 9a3f88eb40
commit 9a3f88eb40df456d5f0c3fcba274a66fb4031a5d
Author: Nhân <hi@imnhan.com>
Date: Sat Aug 19 17:48:06 2023 +0700
don't trim whitespace in djot body
diff --git a/metadata.go b/metadata.go
index ea68c76..c1ef2e6 100644
--- a/metadata.go
+++ b/metadata.go
@@ -183,13 +183,17 @@ func SeparateMetadata(r io.Reader) (metadata []byte, body []byte) {
readingFrontMatter := true
var buffer []byte
for s.Scan() {
- line := bytes.TrimSpace(s.Bytes())
+ line := s.Bytes()
- if readingFrontMatter && bytes.Equal(line, frontMatterSep) {
- metadata = buffer
- buffer = body
- readingFrontMatter = false
- continue
+ if readingFrontMatter {
+ line = bytes.TrimSpace(s.Bytes())
+
+ if bytes.Equal(line, frontMatterSep) {
+ metadata = buffer
+ buffer = body
+ readingFrontMatter = false
+ continue
+ }
}
buffer = append(buffer, line...)