nisus.com
https://www.nisus.com/forum/

Chnage all "st" "nd" etc. to superscript
https://www.nisus.com/forum/viewtopic.php?f=17&t=4316
Page 1 of 1

Author:  Jester [ 2011-05-25 09:39:43 ]
Post subject:  Chnage all "st" "nd" etc. to superscript

Hej!

Is there a macro to change all the "st, nd, rd, th" (that follow a number) to superscript in an entire document?

Grazie,

Author:  Kino [ 2011-05-25 10:03:42 ]
Post subject:  Re: Chnage all "st" "nd" etc. to superscript

Does this work for you?
Code:
Require Pro Version 2.0

define Command SuperscriptOn
   $sp = ':Format:Baseline:Superscript'
   $check = Menu State $sp
   while $check != 1
      Menu $sp
      $check = Menu State $sp
   end
end

$numFound = Find All '(?<=[0-9])(?:st|nd|rd|th)\b', 'E-i'
if ! $numFound
   exit 'Nothing found, exiting…'
else
   SuperscriptOn
end

This one requires NWP 2.0.

EDIT: Removed a redundant command.
EDIT: Fixed a typo in the find expression.

Author:  martin [ 2011-05-25 13:17:52 ]
Post subject:  Re: Chnage all "st" "nd" etc. to superscript

Kino's macro is great if you have an existing document that you need to format nicely, but I just wanted to mention that QuickFix can do this for you automatically as you are typing up new documents. Open up NWP's QuickFix preferences and turn on the option "superscript ordinals" for the desired languages.

Author:  Groucho [ 2011-05-25 22:29:53 ]
Post subject:  Re: Chnage all "st" "nd" etc. to superscript

Hello, Kino.
There’s a tiny flaw in line 12. Unless you plan to have rd always followed by a comma, this…

$numFound = Find All '(?<=[0-9])(?:st|nd|rd,|th)\b', 'E-i’

should be substituted by this…

$numFound = Find All '(?<=[0-9])(?:st|nd|rd|th)\b', 'E-i’

Greetings, Henry.

Author:  Kino [ 2011-05-26 09:09:18 ]
Post subject:  Re: Chnage all "st" "nd" etc. to superscript

Groucho wrote:
There’s a tiny flaw in line 12.
Ah, that's a typo. Thank you for pointing it out.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/