Skip to content

Commit

Permalink
bug(renderer): Section ID should include the icon class (#730)
Browse files Browse the repository at this point in the history
Fixes #691
  • Loading branch information
gdamore authored Jul 17, 2020
1 parent 5dd3224 commit 994c92f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/parser/icon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand Down Expand Up @@ -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"},
Expand Down
10 changes: 10 additions & 0 deletions pkg/types/non_alphanumerics_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 994c92f

Please sign in to comment.