4545import com .vladsch .flexmark .util .format .options .ListSpacing ;
4646import com .vladsch .flexmark .util .html .Attribute ;
4747import com .vladsch .flexmark .util .html .Attributes ;
48+ import com .vladsch .flexmark .util .html .MutableAttributes ;
4849import com .vladsch .flexmark .util .misc .ImageUtils ;
4950import com .vladsch .flexmark .util .misc .Pair ;
5051import com .vladsch .flexmark .util .sequence .BasedSequence ;
@@ -933,7 +934,7 @@ private void render(Link node, DocxRendererContext docx) {
933934 ResolvedLink resolvedLink = docx .resolveLink (LinkType .LINK , node .getUrl ().unescape (), null , null );
934935
935936 // we have a title part, use that
936- Attributes attributes = resolvedLink .getNonNullAttributes ();
937+ MutableAttributes attributes = resolvedLink .getNonNullAttributes (). toMutable ();
937938
938939 if (node .getTitle ().isNotNull ()) {
939940 attributes .replaceValue (Attribute .TITLE_ATTR , node .getTitle ().unescape ());
@@ -1440,9 +1441,7 @@ private void render(LinkRef node, DocxRendererContext docx) {
14401441
14411442 resolvedLink = docx .resolveLink (LinkType .LINK , url , null , null );
14421443 if (reference .getTitle ().isNotNull ()) {
1443- resolvedLink .getNonNullAttributes ().replaceValue (Attribute .TITLE_ATTR , reference .getTitle ().unescape ());
1444- } else {
1445- resolvedLink .getNonNullAttributes ().remove (Attribute .TITLE_ATTR );
1444+ resolvedLink = resolvedLink .withTitle (reference .getTitle ().unescape ());
14461445 }
14471446 } else {
14481447 // see if have reference resolver and this is resolved
@@ -1635,7 +1634,7 @@ public R newImage(DocxRendererContext docx, BufferedImage image, String filename
16351634 private void render (Image node , DocxRendererContext docx ) {
16361635 String altText = new TextCollectingVisitor ().collectAndGetText (node );
16371636 ResolvedLink resolvedLink = docx .resolveLink (LinkType .IMAGE , node .getUrl ().unescape (), null , null );
1638- Attributes attributes = resolvedLink .getNonNullAttributes ();
1637+ MutableAttributes attributes = resolvedLink .getNonNullAttributes (). toMutable ();
16391638
16401639 if (!node .getUrlContent ().isEmpty ()) {
16411640 // reverse URL encoding of =, &
@@ -1667,7 +1666,7 @@ private void render(Emoji node, DocxRendererContext docx) {
16671666 } else {
16681667 ResolvedLink resolvedLink = docx .resolveLink (LinkType .IMAGE , shortcut .emojiText , null , null );
16691668 //String altText = shortcut.alt;
1670- Attributes attributes = resolvedLink .getNonNullAttributes ();
1669+ MutableAttributes attributes = resolvedLink .getNonNullAttributes (). toMutable ();
16711670
16721671 if (shortcut .alt != null ) {
16731672 attributes .replaceValue ("alt" , shortcut .alt );
@@ -1748,9 +1747,7 @@ private void render(ImageRef node, DocxRendererContext docx) {
17481747
17491748 resolvedLink = docx .resolveLink (LinkType .IMAGE , url , null , null );
17501749 if (reference .getTitle ().isNotNull ()) {
1751- resolvedLink .getNonNullAttributes ().replaceValue (Attribute .TITLE_ATTR , reference .getTitle ().unescape ());
1752- } else {
1753- resolvedLink .getNonNullAttributes ().remove (Attribute .TITLE_ATTR );
1750+ resolvedLink = resolvedLink .withTitle (reference .getTitle ().unescape ());
17541751 }
17551752 } else {
17561753 // see if have reference resolver and this is resolved
@@ -1770,7 +1767,7 @@ private void render(ImageRef node, DocxRendererContext docx) {
17701767 }
17711768 } else {
17721769 String altText = new TextCollectingVisitor ().collectAndGetText (node );
1773- Attributes attributes = resolvedLink .getNonNullAttributes ();
1770+ MutableAttributes attributes = resolvedLink .getNonNullAttributes (). toMutable ();
17741771
17751772 if (!altText .isEmpty ()) {
17761773 attributes .replaceValue ("alt" , altText );
@@ -1788,7 +1785,7 @@ private void render(ImageRef node, DocxRendererContext docx) {
17881785 }
17891786 }
17901787
1791- private R renderImage (DocxRendererContext docx , ResolvedLink resolvedLink , Attributes attributes , double scale ) {
1788+ private R renderImage (DocxRendererContext docx , ResolvedLink resolvedLink , MutableAttributes attributes , double scale ) {
17921789 BufferedImage image = null ;
17931790 int id1 = imageId ++;
17941791 int id2 = imageId ++;
@@ -2152,7 +2149,7 @@ private void render(EnumeratedReferenceLink node, DocxRendererContext docx) {
21522149 EnumeratedReferenceRendering [] renderings = enumeratedOrdinals .getEnumeratedReferenceOrdinals (text );
21532150
21542151 String title = new EnumRefTextCollectingVisitor ().collectAndGetText (node .getChars ().getBaseSequence (), renderings , null );
2155- Attributes attributes = new Attributes ();
2152+ MutableAttributes attributes = new MutableAttributes ();
21562153
21572154 if (title != null ) {
21582155 attributes .replaceValue (Attribute .TITLE_ATTR , title );
0 commit comments