I posted this in the regular InDesign forum -- seems that there's no easy solution that would work well in a production environment (only suggestion was to convert the variables to text). However, thought I'd post it here to see if anyone on the scripting forum has a suggestion that might help:
Using InDesign CS4, when there is more than one text variable in a heading that is then included in a generated table of contents, the characters in the table of contents entry are scrambled. Is there a way to avoid this problem so that the table of contents entry has the same text as in the heading?
(This might also have been mentioned in your other thread:)
Text variables work great, but have one big basic flaw: the text cannot be broken. If you have a single text variable contents that's too wide for your text frame, all characters get squished together. I imagine this being even worse when you have two or more variables in a single paragraph. (Another big flaw is that you cannot include character formatting. Let's hope Adobe is working on it.)
You cannot "work around" this basic behavior with a script. The only thing you can do is convert the variables to text, which will de-variablize them (for want of a better word).
Other than using variables, you might want to use the regular Table of Contents feature (which is not "live" but needs updating after each change in the original document text), or perhaps Cross References, which can be used to pick up entire paragraphs.
Thanks for your reply. Is there a fast was to "de-variablize" the all variables in all the chapters of a book?