April 03, 2017

Adding Non-English Book Names to Acc-Insert Verses Service

Update: Version 12.0.5 has fixed this issue. The tutorial now stands as an example of how to do your own custom changes of any sort to an Inserted text.


The Accordance Services allow you to pull all kinds of text out of Accordance and into your current program, without ever leaving the program you're working in. You can see an overview here. It was pointed out on the forums that when using the "Acc-Insert Verses" Service to insert scripture text into your document, that the book names are always in English even if your default language is non-English.
Since the Accordance Services are a type of Automator Workflow, you can customize them to your hearts content. A simple solution, then, is to add a step in the workflow that substitutes all English book names, with the name of your choosing. Here is an example of how to do it.

You can download the Service here, and install it.

All I've done is add a "Run AppleScript" Action that dissects a tab-delimited list of
EnglishName[tab]nonEnglishName
EnglishName[tab]nonEnglishName

EnglishName[tab]nonEnglishName
Hence, you can open up the Service in Automator and customize the list yourself, and save it.

For the Service to work, you need to make sure the "Get Text from Accordance" action has checked to "Use Citation Format", and that in Accordance:Preferences:Citation that you have not checked "Abbreviate book name".

That's all you really need to know to use the custom Service. For the curious, what I did was open the "Acc - Insert Verses" Service and duplicate it and named it with German in the title.

Then I added a new "Run Applescript" action and wrote a script that parses a tab-delimited list, making it easy to edit. The script looks for every instance of the original bookname followed by a space and a digit, replacing as directed. Here is the full text of the AppleScript:

on run {input}
set substitutionList to "Genesis Genesis
Exodus Exodus
Leviticus Levitikus
Numbers Numeri
Deuteronomy Deuteronomium
Joshua Josua
Judges Richter
Ruth Rut
1Samuel 1Samuel
2Samuel 2Samuel
1Kings 1Könige
2Kings 2Könige
1Chronicles 1Chronik
2Chronicles 2Chronik
Ezra Esra
Nehemiah Nehemia
Esther Ester
Job Hiob
Psalms Psalmen
Proverbs Sprichwörter
Ecclesiastes Kohelet
Song Hohelied
Isaiah Jesaja
Jeremiah Jeremia
Lamentations Klagelieder
Ezekiel Ezechiel
Daniel Daniel
Hosea Hosea
Joel Joël
Amos Amos
Obadiah Obadja
Jonah Jona
Micah Micha
Nahum Nahum
Habakkuk Habakuk
Zephaniah Zefanja
Haggai Haggai
Zechariah Sacharja
Malachi Maleachi
Tobit Tobit
Judith Judit
Wisdom Weisheit
Sirach Sirach
Baruch Baruch
1Maccabees 1Makkabäer
2Maccabees 2Makkabäer
1Esdras 1Esdras
Manasseh Manasseh
3Maccabees 3Makkabäer
2Esdras 2Esdras
4Maccabees 4Makkabäer
Matthew Matthäus
Mark Markus
Luke Lukas
Acts Apostelgeschichte
Romans Römer
1Corinthians 1Korinther
2Corinthians 2Korinther
Galatians Galater
Ephesians Epheser
Philippians Philipper
Colossians Kolosser
1Thessalonians 1Thessalonicher
2Thessalonians 2Thessalonicher
1Timothy 1Timotheus
2Timothy 2Timotheus
Titus Titus
Philemon Philemon
Hebrews Hebräer
James Jakobus
1Peter 1Petrus
2Peter 2Petrus
1John 1Johannes
2John 2Johannes
3John 3Johannes
John Johannes
Jude Judas
Revelation Offenbarung"
set theString to input as string
-- Create a tmp sed command file
-- s/foo\( [0-9])/bar\1/g
set tabReplace to "\\( [0-9]\\)/"
set paragraphReplace to "\\1/g
s/"
-- parse the replace string into lists
set commandString to ""
set otid to AppleScript's text item delimiters
set AppleScript's text item delimiters to tab
set commandString to text items of substitutionList
set AppleScript's text item delimiters to tabReplace
set commandString to "s/" & commandString as string
set AppleScript's text item delimiters to return
set commandString to text items of commandString
set AppleScript's text item delimiters to paragraphReplace
set commandString to (commandString as string) & "\\1/g"
set AppleScript's text item delimiters to otid
set commandFilePath to ((path to temporary items from user domain) as text) & "bibleBooks.sed"
try
set fileRef to open for access file commandFilePath with write permission
set eof of fileRef to 0
write commandString to fileRef
close access fileRef
on error
close access fileRef
end try
set posixPath to POSIX path of file commandFilePath
set scriptText to "echo " & quoted form of theString & " | sed -f " & quoted form of posixPath
set theResult to do shell script scriptText
return theResult
end run



April 01, 2017

Clergy Robe with a Handgun Pouch - Have I Now Seen Everything?

I've been looking for a clergy robe that looks better without a tie, and was very surprised to come across this, a preacher's robe with a designated pouch for carrying your gun:


When I did my SBL paper last year on the use of NT passages by Evangelical Christian national leaders when advocating for gun carry, I encountered stories of several ministers who not only went on record as carrying a gun daily, but thought it their vocation to encourage others to carry a gun.
But a preaching robe designed for carrying a gun while leading in worship on Sunday morning? Could it be that prevalent? How big could the market be for this? I guess they've sold some, since the description mentions it just came (back?) in stock today of all days.

I'm not saying that now I've seen everything… but this sure gets me closer.

February 26, 2017

Merriam-Webster Dictionary Lookup Bookmarklet

Here's a bookmarklet for doing a lookup in the online Merriam-Webster Dictionary site.
Just drag this into your favorites bar or bookmark bar.
Mer-WebDict
Once you've done that, you can just highlight any word in a web page and then click on the bookmark, and it will take you to the page for that word.

Cause looking up words is cool.

November 17, 2016

Please Don't Phase out Mac Automation

News broke this week that Apple has eliminated the position of Product Manager of Automation Technologies. Sal was the primary advocate for the continued success and implementation of Applescript and System Services for macOS.
This does not bode well for the future support of Applescript and System Services. I'm guessing Apple wants to phase them out in favor of adopting Siri for everything. The problem is, Siri is not a substitute for the kind of inter-application use many of us rely on. I use scripting daily for my workflows. And, it was essential for some of my research, including my dissertation, over the years.

If you have found any scripts or services useful in your work, including those for Accordance, feel free to join others tweeting out that plea to Apple, using the hash tag #AskApple. 
Here was my tweet:
Worried that Apple eliminated the Product Manager of Automation Technologies. I need Applescript for my academic work. Is all ok?  #AskApple

September 19, 2016

Insert Verses Accordance Service Within Microsoft Word List Paragraph

It turns out that the "Insert Verses" Accordance Service breaks when highlighting a verse reference that begins the line of a List formatted paragraph in a Microsoft Word document.


So, in the above screen shot, you can select the first line and the Insert Verses Accordance Service will work great, but if you try it with the second line (which is formatted in a List style), it results in an error something like:
ERR-A valid book name must be entered at the selection point.
This is true for both Word 2011 and 2016. The reason for this is that when a selection in Word is copied and sent to the clipboard or the Accordance Service, Word "helpfully" includes the list item number or bullet in the copied text. (This is only an issue when the verse reference is at the beginning of the paragraph.)
Instead of just the reference, Word is actually sending:
1.[TAB]Gen 1.1

In Word 2010 for Windows, there is an option in File -> Options -> Advanced -> "Cut, copy, and paste" where you could change "Keep bullets and numbers when pasting text" to "Keep Text Only". This Advanced option does not exist in Word 2011 for Mac. (I do not know if it is available in Word 2016.)

As a fix, you can Get-Your-Geek-On and add a step in the Insert Verses Service to remove everything leading up to any TAB in the selection before sending the reference to Accordance. You can find information about editing or customizing Accordance Services in this blog post: Creating a New Automation Service for Accordance, but here are the basic steps for this tweak:

1. Find the "Acc- Insert Verses" workflow file in ~ / Library / Services.
2. Double-click that file to open it in Automator.
3. Drag a new "Run Applescript" Action from the Actions sidebar into the workflow, above the "Get Text From Accordance" Action.
4. Change the script text to:

on run {input}
set input to input as string
if input contains tab then
set AppleScript's text item delimiters to tab
set input to item 2 of (text items of input)
set AppleScript's text item delimiters to ""
end if
return input

end run

The result should look like this:


5. Save and use.