Has anyone had success in writing a Perl macro that sends the selected text to the macro as RTF (using the #send RTF) option and having the text returned and formatted as RTF?
No. I ported smart/straight quotes macros to NW Express using that macro directive:
<http://quinon.com/files/nisus_files/NWExpressMacros/ RTF_SmartQuotes.pl.sit>
<http://quinon.com/files/nisus_files/NWExpressMacros/ RTF_StraightQuotes.pl.sit>
But '#Send Text as RTF' does not send the selection but the entire file as RTF. So it is usable only when you'd like to process the whole file.
I am a chemistry teacher and would like to design a macro that would take text like Na2SO4 and have the macro drop all numbers to subscripts.
A workaround would be to use real subscript characters U+2080-U+2089 instead of subscript style. Unfortunately, among OS X fonts installed by default, only Skia and some Japanese fonts support those characters and I'm afraid you'll find them not so *sub*. AFAIK Gentium font looks nice. It's free.
<http://www.sil.org/~gaultney/gentium/>
If you find it good, type "Na2SO4" with Gentium, select "Na2SO4" and run the following macro.
#! /usr/bin/perl
#Nisus Macro Block #source clipboard #destination clipboard #before execution #Copy #after execution #Paste #End Nisus Macro Block
### Num2Sub.pl
use strict; use warnings;
my $str = "";
local undef $/; $str = <STDIN>;
if ( $str eq "" ) {
print STDERR "Num2Sub.pl: Nothing selected!\n";
exit;
}$str =~ s/(\d)/\xE2\x82$1/g; $str =~ tr/[0-9]/[\x80-\x89]/; # tr [0-9] into [\xE2\x82\x80-\xE2\x82\x89], # i.e. U+2080-U+2089
print $str;
# end of script
With the current NW Express macro, you cannot check if something is selected or not. So if the clipboard in NOT empty, the content of the clipboard will be pasted even if nothing is selected actually in the edit window. That's a serious defect.
Kino
--------------------------------------------------- The Nisus Interactive List [EMAIL PROTECTED]
Searchable archives: http://www.mail-archive.com/nisus-interactive%40nisus.com/
To unsubscribe from this list please send a message with "unsubscribe nisus-interactive" in the body of the email to [EMAIL PROTECTED]
