[texworks] Qtscripts help

kap4lin kap4lin at gmail.com
Sun Jan 17 04:09:09 CET 2010

On Fri, Jan 15, 2010 at 2:59 PM, Stefan Löffler <st.loeffler at gmail.com> wrote:
> On 2010-01-15 20:02, kap4lin wrote:
>> I am trying to replace the newline character by a space. Why does the
>> following not work?
>> var txt = TW.target.selection;
>> txt = txt.replace(/\n/g,' ');
>> TW.target.insertText(txt);
>> undefined;
> I used Ubuntu Linux, gedit, and copied from the page
> http://unicode.coeurlumiere.com/?n=8192 (note that I didn't see any
> selection when selecting the character U+2029 - but it is there). The
> character was rendered as a newline, but the script worked.

That was some freaky stuff! But worked though!!

On Fri, Jan 15, 2010 at 3:02 PM, Jonathan Kew <jfkthame at googlemail.com> wrote:
>  txt.replace(/\u2029/g, ' ');
> to achieve what you're trying to do here.

That did not work! I typed, literally, \u2029. But Stefan's copy paste worked!

> (BTW, with the new script APIs you no longer need to ensure you return "undefined" from a QtScript to avoid getting a result dialog; to actually return something, you'd have to explicitly assign to TW.result.)


http://counter.li.org  #402424

More information about the texworks mailing list