Macro-Bible book name abbreviations

Get help using and writing Nisus Writer Pro macros.
Post Reply
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Macro-Bible book name abbreviations

Post by NisusUser »

I'm wondering how to make a macro that will change all of the following 66 abbreviations (some are also full words: Song, Job, Jude, so I only want them to be changed when at least one digit, a colon and at least one other digit follow them, i.e. "Song 1:1" should change to "Gg 1:1", but if "Song" or "song" is elsewhere in the text that word without reference numbers should not be changed):
Ge
Ex
Le
Nu
De
Jos
Jg
Ru
1Sa
2Sa
1Ki
2Ki
1Ch
2Ch
Ezr
Ne
Es
Job
Ps
Pr
Ec
Song
Isa
Jer
La
Eze
Da
Ho
Joe
Am
Ob
Jon
Mic
Na
Hab
Zep
Hag
Zec
Mal
Mt
Mr
Lu
Joh
Ac
Ro
1Co
2Co
Ga
Eph
Php
Col
1Th
2Th
1Ti
2Ti
Tit
Phm
Heb
Jas
1Pe
2Pe
1Jo
2Jo
3Jo
Jude
Re

I would like to change them to these abbreviations with non-breaking spaces between all the Roman numerals and the following text:

Pr

Kun
Sk
Įst
Joz
Ts
Rūt
I Sam
II Sam
I Kar
II Kar
I Met
II Met
Ezr
Neh
Est
Job
Ps
Pat
Mok
Gg
Iz
Jer
Rd
Eze
Dan
Oz
Jl
Am
Abd
Jon
Mch
Nah
Hab
Sof
Ag
Zch
Mal
Mt
Mk
Lk
Jn
Apd
Rom
I Kor
II Kor
Gal
Ef
Flp
Kol
I Tes
II Tes
I Tim
II Tim
Tit
Fm
Hbr
Jok
I Pt
II Pt
I Jn
II Jn
III Jn
Jud
Apr

Some abbreviations are identical (e.g. Job > Job, Ps > Ps), but I want to include them all so that if I later want to copy and make another macro with long names of the books, I can just substitute in the whole names.

There is one other thing I'd like added to this macro. Five of the 66 books of the Bible only have one chapter, but the data I want to run this macro on will have references that are not quite proper. E.g., Jude only has one chapter, but the initial data I'm getting has "Jude 1:1", when the proper reference is just "Jude 1". This is true for Obadiah, Philemon, 2 John, 3 John, and Jude (they are in bold above). I'd like the macro to also delete the "1:" before each reference for each of the verses from these books.

I think it'd be best if the macro worked on selected text. Then if I want to do the whole document, I can, or if not, I can just select a portion. But if automatically does the entire text, it may be too much.

If someone could give me some pointers as to an efficient way to do this, I'm game to try :). However, thinking "computer-like" does not come naturally to me.

Thank you. -Eric
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro-Bible book name abbreviations

Post by phspaelti »

Hello Eric,
yes this can be done with a macro. The basic operation is done with Find and Replace and once you get that working you can save it as a macro. In your case you would need to use PowerFind or PowerFind Pro. Since PowerFind does not travel well, I am going to use PowerFind Pro.

The basic replace statement that you would need will look like this for the Song case:

Code: Select all

Find and Replace 'Song(?= \d\:\d)', 'Gg', 'Esaw-iS'
The 'Esaw-iS' part at the end tells Nisus to:
  • use Powerfind Pro (E)
  • replace in the selection only (s)
  • catch all cases (a)
  • match words only (w)
  • not ignore case (-i)
  • and keep the selection for the next Find/Replace (S)
The (?= \d\:\d) tells Nisus to make sure the Song is followed by "space-digit-column-digit".

Now you can just paste that statement into a macro, multiply it and then replace "Song" and "Gg" with the other cases. I actually did this and the result is as follows:
Bible_replace.nwm
(21.66 KiB) Downloaded 773 times
But this still leaves out the second request. To that I actually have a question. Jude 1:1 should become Jud 1. OK. But what about Jude 2:1 (assuming there is such a thing) is that Jud 2 or Jud 1?

Anyhow so much for now.
philip
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Re: Macro-Bible book name abbreviations

Post by NisusUser »

Thanks for your help, Philip.
But what about Jude 2:1 (assuming there is such a thing) is that Jud 2 or Jud 1?
There will be no 2:1 or anything like 2:x in the original texts from these books since they only have one chapter.

I failed to mention that for those 5 books, it's also relevant that sometimes you get more than one digit after the colon, e.g., "Jude 1:1-25" that needs to be changed to "Jud 1-25".
Last edited by NisusUser on 2012-11-28 21:29:16, edited 1 time in total.
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro-Bible book name abbreviations

Post by phspaelti »

Ok then so one approach for Jude would be:

Code: Select all

Find and Replace 'Jude \d\:(?=\d)', 'Jud ', 'Esa-iS'
And the same for the other four.

But I just noticed one more thing. I noticed that you want to replace "Ge" with "Pr" and then also "Pr" with "Pat". Do you see the problem? This kind of thing gives a cascade, unless you are very careful to do things in the right order.

The safest thing to do is to insert some kind of completion marker for each replacement, and then remove the marker at the end. But that is a bit of nuisance. (And you have to be really sure the completion marker won't cause other problems.)

In this case, as the "Pr" is the only case I found you can just put the "Ge" -> "Pr" replacement at the end. But since you were talking about changing the replacements you might want to look out for this type of problem in the future.
Bible_replace_v2.nwm
(21.73 KiB) Downloaded 760 times
philip
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Re: Macro-Bible book name abbreviations

Post by NisusUser »

Excellent, Philip!
I noticed that you want to replace "Ge" with "Pr" and then also "Pr" with "Pat". Do you see the problem? This kind of thing gives a cascade, unless you are very careful to do things in the right order.
Yes, I see the problem, and I had noticed that earlier (maybe when manually doing find-change one at a time). But it slipped my mind today. Your macro works great!!

Eric
Last edited by NisusUser on 2012-11-28 21:28:56, edited 1 time in total.
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Re: Macro-Bible book name abbreviations

Post by NisusUser »

About non-breaking spaces between the Roman numerals and the abbreviations: how can I add that to the macro? I assume there is some regex code for non-breaking space, right?

Thanks!
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro-Bible book name abbreviations

Post by phspaelti »

Isn't non-breaking space "option space"? I thought I had put them in. You don't really need a code. Just type them.

But if you prefer you could put them in using codes. The code for a non-breaking space is "\u00A0". So for example:

Code: Select all

Find and Replace '1Sa(?= \d\:\d)', 'I\u00A0Sam', 'Esaw-iS'
philip
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Re: Macro-Bible book name abbreviations

Post by NisusUser »

Thanks again, Philip. I think I've got the non-breaking spaces in (they show up as transparent tildes (~) when Show Invisibles (Ctrl-Cmd I) is selected. I'll attach the macro file just in case someone wants to use it as a basis for something similar.

I appreciate all your help!
Attachments
EC-Bible_Abbr_Change_v3.2 SELECTION ONLY.nwm
(4.19 KiB) Downloaded 694 times
Post Reply