Skip to content

Commit

Permalink
refactor(parser): do not reparse image 'alt' attribute
Browse files Browse the repository at this point in the history
only apply attribute substitutions

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon committed May 16, 2022
1 parent 8c2d04a commit 13c98b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pkg/parser/document_processing_apply_substitutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func reparseAttributes(e types.WithAttributes, subs []string, opts ...Option) er
}
for k, v := range attributes {
switch k {
case types.AttrTitle, types.AttrXRefLabel, types.AttrInlineLinkText, types.AttrImageAlt:
case types.AttrTitle, types.AttrXRefLabel, types.AttrInlineLinkText:
v, err := ReparseAttributeValue(v, subs, opts...)
if err != nil {
return err
Expand Down
28 changes: 2 additions & 26 deletions pkg/parser/document_processing_apply_substitutions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,19 +333,7 @@ var _ = Describe("apply substitutions", func() {
Elements: []interface{}{
&types.InlineImage{
Attributes: types.Attributes{
types.AttrImageAlt: []interface{}{
&types.QuotedText{
Kind: types.SingleQuoteItalic,
Attributes: types.Attributes{
types.AttrRoles: types.Roles{"role_1"},
},
Elements: []interface{}{
&types.StringElement{
Content: "yummy!",
},
},
},
},
types.AttrImageAlt: "[.role_1]_yummy!_",
},
Location: &types.Location{
Path: "yummy.png",
Expand Down Expand Up @@ -505,19 +493,7 @@ var _ = Describe("apply substitutions", func() {
Elements: []interface{}{
&types.InlineImage{
Attributes: types.Attributes{
types.AttrImageAlt: []interface{}{
&types.QuotedText{
Kind: types.SingleQuoteItalic,
Attributes: types.Attributes{
types.AttrRoles: types.Roles{"role_1"},
},
Elements: []interface{}{
&types.StringElement{
Content: "yummy row!",
},
},
},
},
types.AttrImageAlt: "[.role_1]_yummy row!_",
},
Location: &types.Location{
Path: "yummy.png",
Expand Down

0 comments on commit 13c98b7

Please sign in to comment.