[TextMesh Pro] Unable to set character invisible

I am attempting to create a custom set of rich text tags in TextMeshPro but am having a bit of trouble hiding the tags after determining what text to effect. The effect itself works, no issue with that, but the tags won’t disappear like I would like.

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;

//Adapted from the TMP vertex jitter example
public class TMPSquiggleTag : MonoBehaviour {
	private TMP_Text m_TextComponent;
	private bool hasTextChanged;

	void Awake() {
		m_TextComponent = GetComponent<TMP_Text>();
	}

	void OnEnable() {
		// Subscribe to event fired when text object has been regenerated.
		TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
	}

	void OnDisable() {
		TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
	}


	void Start() {
		StartCoroutine(DoSquiggle());
	}


	void ON_TEXT_CHANGED(Object obj) {
		if (obj == m_TextComponent)
			hasTextChanged = true;
	}

	IEnumerator DoSquiggle () {
		m_TextComponent.ForceMeshUpdate(); //force the mesh to be generated before the end of the frame
		
		TMP_TextInfo textInfo = m_TextComponent.textInfo;
		TMP_MeshInfo[] cachedMeshInfo = textInfo.CopyMeshInfoVertexData();
		Matrix4x4 matrix;
		hasTextChanged = true;
		List<int> squiggleChars = new List<int>();

		while (true) {
			if (hasTextChanged) {
				cachedMeshInfo = textInfo.CopyMeshInfoVertexData(); // Update the copy of the vertex data for the text object.
				//make the squiggle tag characters invisible and record what characters should wiggle
				squiggleChars.Clear();
				if (m_TextComponent.text.Contains(@"<squiggle>") && m_TextComponent.text.Contains(@"</squiggle>")) {
					int beginSearch = 0;
					for (int i = 0; i < Regex.Matches(m_TextComponent.text,@"<squiggle>").Count; i++) {
						int beginBracket = m_TextComponent.text.IndexOf(@"<squiggle>",beginSearch);
						int endBracket = m_TextComponent.text.IndexOf(@"</squiggle>",beginSearch);
						//hide brackets
						for (int j = beginBracket; j < beginBracket + 10; j++) textInfo.characterInfo[j].isVisible = false;
						for (int j = endBracket; j < endBracket + 11; j++) textInfo.characterInfo[j].isVisible = false;
						//put down the correct characters to be squiggled
						for (int c = beginBracket+10; c < endBracket; c++) {
							squiggleChars.Add(c);
						}
						//make sure you dont just keep doing this pair of squiggle tags if there's others to do
						beginSearch = endBracket;
					}
				}

				hasTextChanged = false;
			}
			
			int characterCount = textInfo.characterCount;
			if (characterCount == 0) { yield return new WaitForSeconds(0.25f); continue; } //wait for text to be added, if its not already

			for (int i = 0; i < characterCount; i++) {
				TMP_CharacterInfo charInfo = textInfo.characterInfo*;*
  •  		if (!charInfo.isVisible) continue; //skip invisible characters (the squiggle tags)*
    
  •  		//offset the vertical position by sine(character index in string)*
    
  •  		if (squiggleChars.Contains(i)) {*
    

//…

  •  		}*
    
  •  	}*
    
  •  	yield return new WaitForSeconds(0.05f);*
    
  •  }*
    
  • }*
    }
    As far as I can tell the issue is with the lines
    for (int j = beginBracket; j < beginBracket + 10; j++) textInfo.characterInfo[j].isVisible = false;
    and
    for (int j = endBracket; j < endBracket + 11; j++) textInfo.characterInfo[j].isVisible = false;
    since they dont actually set the <squiggle> and </squiggle> to be invisible.
    An example of the current, unintended, behavior is:
    [112802-unity-2018-03-11-14-04-37.png|112802]*
    Thanks for your help!

any solution for this?