From 994c92f151f719b16c6e43e5ac2fa2e98c34259a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 16 Jul 2020 23:13:03 -0700 Subject: [PATCH] bug(renderer): Section ID should include the icon class (#730) Fixes #691 --- pkg/parser/icon_test.go | 4 ++-- pkg/types/non_alphanumerics_replacement.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/parser/icon_test.go b/pkg/parser/icon_test.go index 67c28a9d..58c7fa07 100644 --- a/pkg/parser/icon_test.go +++ b/pkg/parser/icon_test.go @@ -138,7 +138,7 @@ var _ = Describe("icons", func() { Blocks: []interface{}{ types.Section{ Attributes: types.Attributes{ - types.AttrID: "_a_from_me", // TODO: missing icon class + types.AttrID: "_a_note_from_me", }, Level: 1, Title: []interface{}{ @@ -166,7 +166,7 @@ var _ = Describe("icons", func() { types.Section{ Level: 0, Attributes: types.Attributes{ - types.AttrID: "_or_what_to_do", // TODO: should be "_warning_or_what_note_to_do" + types.AttrID: "_warning_or_what_note_to_do", }, Title: []interface{}{ types.Icon{Class: "warning"}, diff --git a/pkg/types/non_alphanumerics_replacement.go b/pkg/types/non_alphanumerics_replacement.go index 6492c5fb..40345a2b 100644 --- a/pkg/types/non_alphanumerics_replacement.go +++ b/pkg/types/non_alphanumerics_replacement.go @@ -41,6 +41,16 @@ func ReplaceNonAlphanumerics(elements []interface{}, replacement string) (string buf.WriteString(replacement) } buf.WriteString(r) + case Icon: + s := element.Attributes.GetAsStringWithDefault(AttrImageAlt, element.Class) + r, err := replaceNonAlphanumerics(s, replacement) + if err != nil { + return "", err + } + if buf.Len() > 0 { + buf.WriteString(replacement) + } + buf.WriteString(r) default: // other types are ignored }