@@ -667,8 +667,11 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
667667 } else if n .IsTextMarkType ("a" ) {
668668 if replaceTypes ["aText" ] {
669669 if 0 == method {
670- if strings .Contains (n .TextMarkTextContent , keyword ) {
671- n .TextMarkTextContent = strings .ReplaceAll (n .TextMarkTextContent , keyword , replacement )
670+ content := util .UnescapeHTML (n .TextMarkTextContent )
671+ if strings .Contains (content , escapedKey ) {
672+ n .TextMarkTextContent = strings .ReplaceAll (content , escapedKey , replacement )
673+ } else if strings .Contains (content , keyword ) {
674+ n .TextMarkTextContent = strings .ReplaceAll (content , keyword , replacement )
672675 }
673676 } else if 3 == method {
674677 if nil != r && r .MatchString (n .TextMarkTextContent ) {
@@ -683,8 +686,11 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
683686
684687 if replaceTypes ["aTitle" ] {
685688 if 0 == method {
686- if strings .Contains (n .TextMarkATitle , keyword ) {
687- n .TextMarkATitle = strings .ReplaceAll (n .TextMarkATitle , keyword , replacement )
689+ title := util .UnescapeHTML (n .TextMarkATitle )
690+ if strings .Contains (title , escapedKey ) {
691+ n .TextMarkATitle = strings .ReplaceAll (title , escapedKey , replacement )
692+ } else if strings .Contains (n .TextMarkATitle , keyword ) {
693+ n .TextMarkATitle = strings .ReplaceAll (title , keyword , replacement )
688694 }
689695 } else if 3 == method {
690696 if nil != r && r .MatchString (n .TextMarkATitle ) {
@@ -695,8 +701,11 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
695701
696702 if replaceTypes ["aHref" ] {
697703 if 0 == method {
698- if strings .Contains (n .TextMarkAHref , keyword ) {
699- n .TextMarkAHref = strings .ReplaceAll (n .TextMarkAHref , keyword , strings .TrimSpace (replacement ))
704+ href := util .UnescapeHTML (n .TextMarkAHref )
705+ if strings .Contains (href , escapedKey ) {
706+ n .TextMarkAHref = strings .ReplaceAll (href , escapedKey , util .EscapeHTML (replacement ))
707+ } else if strings .Contains (href , keyword ) {
708+ n .TextMarkAHref = strings .ReplaceAll (href , keyword , strings .TrimSpace (replacement ))
700709 }
701710 } else if 3 == method {
702711 if nil != r && r .MatchString (n .TextMarkAHref ) {
0 commit comments