"|" character appears inside of a string containing linear box syntax,
False and FrontEnd often fails to display the string correctly. Consider:
A string with an alphabetical character embedded in linear box syntax, it's OK:
"\!\(\*StyleBox[\"a\"]\)" // SyntaxQ
When we put the
"|"character (which is ASCII!), something goes wrong:
"\!\(\*StyleBox[\"|\"]\)" // SyntaxQ
Well, let us take what Mathematica suggests:
str = ToString[Style["|"], StandardForm]; str // SyntaxQ str // InputForm
True "\!\(\*StyleBox[\"\\\"|\\\"\", Rule[StripOnInput, False]]\)"
Now it looks OK, but I wish to have additional
"|" in the string, so I try:
str <> "|" // SyntaxQ
Again something goes wrong (but why???), while with the alphabetical characters it's OK:
str <> "a" // SyntaxQ
str with itself is also OK, but I don't wish to blow up my file having every
"|" character wrapped by the linear syntax. The above is just a minimal working example, of course. Actually I'm constructing a string containing both
Plain (the default style) symbols
I'm working with large strings and wish to keep them as small in size as possible and I'm also trying to make the script as efficient as possible, hence I wish to avoid excessive linear syntax inside of the strings where it isn't strictly necessary.
What is the correct way to compose a large string with differently styled
"|" characters? The string have to be as small as possible, with default formatting applied to unstyled characters.