Reply to topic  [ 5 posts ] 
Chnage all "st" "nd" etc. to superscript 
Author Message
User avatar

Joined: 2009-05-21 11:53:23
Posts: 158
Location: Midway through infinity (or Ottawa, Canada).
Hej!

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

Grazie,

_________________
Translation for you:

http://paralleltranslations.ca/translation/


2011-05-25 09:39:43
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
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.


Last edited by Kino on 2011-05-26 09:09:58, edited 2 times in total.



2011-05-25 10:03:42
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2011-05-25 13:17:52
Profile WWW

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
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.


2011-05-25 22:29:53
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
Groucho wrote:
There’s a tiny flaw in line 12.
Ah, that's a typo. Thank you for pointing it out.


2011-05-26 09:09:18
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software