From 13c98b785bd9414d4e926d89d168a79dc3d523e4 Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Mon, 16 May 2022 12:41:46 +0200 Subject: [PATCH] refactor(parser): do not reparse image 'alt' attribute only apply attribute substitutions Signed-off-by: Xavier Coulon --- ...document_processing_apply_substitutions.go | 2 +- ...ent_processing_apply_substitutions_test.go | 28 ++----------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/pkg/parser/document_processing_apply_substitutions.go b/pkg/parser/document_processing_apply_substitutions.go index 6f1cedcb..a2ceface 100644 --- a/pkg/parser/document_processing_apply_substitutions.go +++ b/pkg/parser/document_processing_apply_substitutions.go @@ -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 diff --git a/pkg/parser/document_processing_apply_substitutions_test.go b/pkg/parser/document_processing_apply_substitutions_test.go index 72cd0c57..0f5bf81a 100644 --- a/pkg/parser/document_processing_apply_substitutions_test.go +++ b/pkg/parser/document_processing_apply_substitutions_test.go @@ -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", @@ -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",