The output I get with that example command is a literal "This is a {TXT:testVar}!", which is to be expected as the tokens use also uses curly braces, just as the Rich Text Markup does, so they're both escaped and therefore not parsed by the token parser.
You can either manually remove the pipe ("|") symbols and the backslash escape characters from the braces of the token in your "Set a Text Value" action, or you can use different characters (that you wouldn't normally use as part of the text itself), like "[" instead of "{", and "]" instead of "}", and have the inline function replace those with curly braces
E.G.
using System;
using System.Text;
using System.Windows.Forms;
public class VAInline
{
public void main()
{
string richText = VA.GetText("richText");
if (!String.IsNullOrEmpty(richText))
{
Clipboard.SetText(richText.Replace("{", "|{").Replace("\r\n", "{NEWLINE}").Replace("[", "{").Replace("]", "}"));
}
else
{
VA.WriteToLog("No text to paste", "red");
}
}
}
Do note that if the text in any variable value you're retrieving using a token contains curly braces, those should be escaped using backslash characters, as otherwise the Rich Text parser (in the application your pasting into) will likely attempt to interpret them part of the markup
The same would likely apply to backslashes, which should be doubled up (I.E. "\\" instead of "\")
EDIT: That'll happen when you don't remove the backslashes, which are used as escape characters in the markup for the curly braces.
The literal text would be "\Sputnik\", which causes the Rich Text parser to interpret it incorrectly
EDIT#2: Actually, given that curly braces need to be escaped when part of the text content, it stands to reason that an escaped brace therefore cannot be part of the markup
This modified inline function will first replace any escaped opening curly braces with a temporary non-printable character (I.E. one that should never be part of the copied text, so no conflicts arise), replace escaped closing braces to remove the escape character, escape any remaining opening braces that weren't escaped in the Rich Text markup for the token parser, and then replace the temporary characters with their final regular opening curly brace:
using System;
using System.Text;
using System.Windows.Forms;
public class VAInline
{
public void main()
{
string openingBraceSubstitute = ((char)2).ToString();
string richText = VA.GetText("richText");
if (!String.IsNullOrEmpty(richText))
{
Clipboard.SetText(richText.Replace("\\{", openingBraceSubstitute).Replace("\\}", "}").Replace("\r\n", "{NEWLINE}").Replace(openingBraceSubstitute, "{"));
}
else
{
VA.WriteToLog("No text to paste", "red");
}
}
}