Hi. Thanks for all your help.
I've been writing stuff using a lot of twinescript and I just realised I need to run a regex at the end to clean up some grammar mistakes.
Is the text printed into Twinescript saved to a variable somewhere before it's output to the page? I could just regex that in javascript. Alternatively, is there a way to make a replace function fire on the entire passage or an entire element right before it becomes visible to the reader using TwineScript somehow?
TLDR: This is basically my problem. How do I fix it without changing anything inside the print macro?
<<print "I want to edit this text so that an big elephant becomes a big elephant">>
Comments
Is there a reason you can't do this in the passage editor? What you're proposing seems like using a sledgehammer to do a scalpel's job is all. Why isn't just altering the test in the editor an option?
At first blush, what you're asking for is nonsensical. If what you want to change are mistakes in the original source, then you should correct them there, before you compile the project. Elsewise, if you simply want some dynamism in your content, then you already have the power to use variables and macros within your markup.
That said. I get the feeling that you're not explaining your situation very well and this situation is less crazy than it sounds.
If you're randomly generating some text, then either generate it correctly in the first place or store it within a variable as you generate it, so that you may correct it before you output it. The former would, obviously, be the best thing to do, though the latter is workable at least.
Without some detailed examples of how you're dynamically generating the text in question, it's difficult to offer advice on how to best address your situation.