diff --git a/claat/parser/md/parse.go b/claat/parser/md/parse.go index 677036fd7..62e64cf86 100644 --- a/claat/parser/md/parse.go +++ b/claat/parser/md/parse.go @@ -38,16 +38,17 @@ import ( "github.com/russross/blackfriday" ) +// Metadata constants for the YAML header const ( - metaAuthor = "author" - metaSummary = "summary" - metaID = "id" - metaCategories = "categories" - metaEnvironments = "environments" - metaStatus = "status" - metaFeedbackLink = "feedback link" - metaAnalyticsAccount = "analytics account" - metaTags = "tags" + MetaAuthor = "author" + MetaSummary = "summary" + MetaID = "id" + MetaCategories = "categories" + MetaEnvironments = "environments" + MetaStatus = "status" + MetaFeedbackLink = "feedback link" + MetaAnalyticsAccount = "analytics account" + MetaTags = "tags" ) const ( @@ -351,40 +352,40 @@ func standardSplit(s string) []string { func addMetadataToCodelab(m map[string]string, c *types.Codelab) error { for k, v := range m { switch k { - case metaAuthor: + case MetaAuthor: // Directly assign the summary to the codelab field. c.Author = v - case metaSummary: + case MetaSummary: // Directly assign the summary to the codelab field. c.Summary = v break - case metaID: + case MetaID: // Directly assign the ID to the codelab field. c.ID = v break - case metaCategories: + case MetaCategories: // Standardize the categories and append to codelab field. c.Categories = append(c.Categories, standardSplit(v)...) break - case metaEnvironments: + case MetaEnvironments: // Standardize the tags and append to the codelab field. c.Tags = append(c.Tags, standardSplit(v)...) break - case metaStatus: + case MetaStatus: // Standardize the statuses and append to the codelab field. statuses := standardSplit(v) statusesAsLegacy := types.LegacyStatus(statuses) c.Status = &statusesAsLegacy break - case metaFeedbackLink: + case MetaFeedbackLink: // Directly assign the feedback link to the codelab field. c.Feedback = v break - case metaAnalyticsAccount: + case MetaAnalyticsAccount: // Directly assign the GA id to the codelab field. c.GA = v break - case metaTags: + case MetaTags: // Standardize the tags and append to the codelab field. c.Tags = append(c.Tags, standardSplit(v)...) break @@ -651,7 +652,7 @@ func image(ds *docState) types.Node { } if ws := nodeAttr(ds.cur, "width"); ws != "" { - w,err := strconv.ParseFloat(ws, 64) + w, err := strconv.ParseFloat(ws, 64) if err != nil { return nil } diff --git a/claat/render/md.go b/claat/render/md.go index c3c207563..79edc9c36 100644 --- a/claat/render/md.go +++ b/claat/render/md.go @@ -126,7 +126,7 @@ func (mw *mdWriter) write(nodes ...types.Node) error { func (mw *mdWriter) text(n *types.TextNode) { if n.Bold { - mw.writeString("__") + mw.writeString("**") } if n.Italic { mw.writeString(" *") @@ -142,7 +142,7 @@ func (mw *mdWriter) text(n *types.TextNode) { mw.writeString("* ") } if n.Bold { - mw.writeString("__") + mw.writeString("**") } } @@ -242,6 +242,9 @@ func (mw *mdWriter) infobox(n *types.InfoboxNode) { // TODO: This should use the "detail item" syntax so that it can be pure MD and not HTML // kind // : + // + // The main issue is that when you do write(n.Content.Nodes...) it always adds two newlines + // at the beginning. mw.newBlock() mw.writeString(`