Conversation
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
7fd04ad to
92d712c
Compare
bwplotka
left a comment
There was a problem hiding this comment.
Thank you for fixing this issue 🤗
Good work, some early suggestions 💪🏽
pkg/mdformatter/mdformatter.go
Outdated
| for _, k := range keys { | ||
| _, _ = fmt.Fprintf(b, "%v: %v\n", k, frontMatter[k]) | ||
| // check if frontMatter[k] is a map | ||
| frontMatterStr := fmt.Sprintf("%s", frontMatter[k]) |
There was a problem hiding this comment.
This is nice tricky, but wonder if we could add some type safety (: Would _, isMap := frontMatter[k].(map[string]interface{}) work? 🤔
There was a problem hiding this comment.
Will check it out!
There was a problem hiding this comment.
Looks like it worked! Do we need frontMatterStr then? 🤗
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
6a56309 to
bb3e604
Compare
|
Linting issues have been fixed @bwplotka. |
pkg/mdformatter/mdformatter.go
Outdated
| for _, k := range keys { | ||
| _, _ = fmt.Fprintf(b, "%v: %v\n", k, frontMatter[k]) | ||
| // check if frontMatter[k] is a map | ||
| frontMatterStr := fmt.Sprintf("%s", frontMatter[k]) |
There was a problem hiding this comment.
Looks like it worked! Do we need frontMatterStr then? 🤗
pkg/mdformatter/mdformatter.go
Outdated
| _, _ = fmt.Fprintf(b, "%v: %v\n", k, frontMatter[k]) | ||
| // Check if frontMatter[k] is a map. | ||
| frontMatterStr := fmt.Sprintf("%s", frontMatter[k]) | ||
| _, isMap := frontMatter[k].(map[string]interface{}) |
There was a problem hiding this comment.
Actually we can do better. Since you are casting to map we could use this map directly, no need to use frontMatterStr, no? (:
There was a problem hiding this comment.
Oh yes. Will make the changes!
There was a problem hiding this comment.
Used the casted map. Code looks better now!
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
| b := bytes.NewBuffer([]byte("---")) | ||
| for _, k := range keys { | ||
| _, _ = fmt.Fprintf(b, "%v: %v\n", k, frontMatter[k]) | ||
| // Check if frontMatter[k] is a map. |
There was a problem hiding this comment.
For the next time, this comment might be not needed - the code is now nicely self-explanatory (:

This PR fixes the frontmatter issue, where frontmatter in md being formatted led to
maps showing up. Now,mdformatter.gocorrectly processes nested fields. Fixes issue #13The above frontmatter generated before fix.
The above frontmatter generated after fix.