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.

April 29, 2016

Accessing Accordance from the Command Line in Terminal

I was talking with someone today about how you might grab a text reference from Accordance without leaving the command line in Terminal. So, I thought I'd share one way to accomplish it.

You can use Applescript to retrieve the full text of verse references from a given text module, all without bringing Accordance to the front or interacting with its interface in any way. This is how my old scripts and actions have worked, as well as some the OS X Services that OakTree packages with Accordance.
A raw Applescript line to get the text of John 1:1 from the NRSVS module using the citation format (true) is:

tell app "Accordance" to get «event AccdTxRf» {"NRSVS", "John 1:1", true}
You can call that from the shell using osascript:

osascript -e 'tell app "Accordance" to get «event AccdTxRf» {"NRSVS", "John 1:1", true}'
But, no-one wants to type that out each time you want to lookup a verse, so you'll want to create a shell script that passes the verse reference as an argument to the script. Here's an example:

# This script takes a verse reference as an argument to return the full text of the reference to stdout
# chmod +x 
# ./

# set the short name of module to use
# set to "true" to use citation format

# trap for a null argument passed, since Accordance crashes if it receives a null parameter
if [ -n "$*" ] #[ "$#" -gt 0 ] 
# retrieve all passed arguments as one string, so you can pass references with spaces and without quotes: John 1:1

# get the text of the reference from Accordance
textresult=$(osascript -e "tell app \"Accordance\" to get «event AccdTxRf» {\"$modulename\", \"$verseref\", $usecitation}")

echo "$textresult"

    echo "Must pass a text reference as a variable, as in:  getverse John 1:1"
Save that as a text file in your home folder ( ~/ ) with a name like ''. You'll also need to make it executable by going to the Terminal and using:

chmod +x
After that, you can call the script from the command line in Terminal with:

./ John 11:35

An additional, welcome, step is to create an alias that calls that script, to further reduce what you have to type to run it.  Open up your bash profile at ~/.bash_profile (it likely doesn't exist yet, so you'll have to create it),  and then add a line to it to create the alias:

alias gv=./
After that, you'll need to initiate the bash shell environment with this command in Terminal:

source ~/.bash_profile
Then, you can just type: gv John 1:1, 3
to lookup your verse references.

I glossed over some details, assuming that if you're at all interested in doing what this post suggests, you are already familiar with the subjects and functions covered.

April 01, 2016

New Tesla Design Makes It the Apple of Autos

Tesla is the high-end electric car company, headed by an eccentric and high-profile CEO, that makes the incredible electric car that so many want but so few can afford. This has earned them the moniker "the Apple of Automobiles".
Tesla made big news today for revealing the design of their Model 3, which is still in production, but will start at $35,000. In just a day, 115,000 people have reserved their car, all based on the dramatic release of this one photo. Just take a look at the design photo they released, and you can see what has so many people excited:

Tesla Model 3
I am excited about this.
The single photo offers a limited scope of what's in store for the newest electric car, but a couple things revealed here have me thrilled. Immediately most controversial I suspect would be the two discreet passenger compartments. The world of tech and social sciences both have skyrocketed into the pursuit of specialization, so the inevitable result is division between passengers and operators. Several may find this off-putting, but I have two kids, and it strikes me as genius.

You can also notice Jobsesque attention to detail, such as the step ladder and the doubled headlights. Many have already been speculating about the extra headlights. What could they be for? Extra visibility. Some are suggesting that the second pair of headlights could be designed to shift the light spectrum away from intense blue light after 10pm.
The company is not saying much more, other than the availability of a few luxury and tech-related add-on options. The most intriguing the description of a deck, that then became associated with this (leaked?) picture.

They are calling an "eight track deck". I assume it is some sort of audio (bluetooth?) interface that allows you to connect up to eight iOS devices at once. At the press release, a design engineer Max Campbell was very enthusiastic about this technology.
Here's my speculation: could this new car, along with this add-on, be some type of coordination between Tesla and Apple into the new frontier of self-driving cars? Maybe you set up the directions on your phone, and then just plug it into the deck and the car takes over from there?  One can dream.

Without much revealed, we'll have to wait for more info, though that's not preventing auto and tech pundits alike from already drawing their own conclusions.
Technology aficionado John Gruber tweeted this about the upcoming car: "I think it has a classic, almost Homeric quality."

March 03, 2016

Script to Paste Clipboard with Specific Font

A friend asked about a script to copy selected text and paste it into Word in a specified font face. My mind explodes with all the different ways, technologies one could do this with—Applescript, Automator, VBA within Word, and launcher/macro programs like KeyboardMaestro and Quicksilver.

Let's say you found the relevant text or from a PDF or website or in Accordance and you want to copy and paste it into your Word document, but you want to specify the font because it's a different language than your other normal text.*

I'd like to illuminate one little trick I learned some time ago that can be incorporated into several of those. Namely, you can use the command line textual tool to markup the text with the much-maligned HTML tag and then copy it to the clipboard converting the HTML text to styled text. The syntax for the line is:
echo '<i>I am some italicized text</i>' | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf
I normally would wrap that into a script which grabs the text and then pastes it wherever I want it. Here's an example of a script, which copies the selected text in the front app, then reads the clipboard into variable, adds a tag to the text of the variable, then copies that newly-styled text back onto the clipboard, and then brings Word to the front, and pastes the directly formatted text.

-- copy the text
tell application "System Events"
keystroke "c" using {command down}
end tell
delay 0.1
set myText to the clipboard
delay 0.1

-- add HTML style data to the text
set myText to "<font face=\"SBL BibLit\" size=3>" & myText"</font>"

-- convert the styled html text as styled text on the clipboard
do shell script "echo " & quoted form of myText & ¬
" | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"

-- paste the newly styled keyboard into an app
tell application "Microsoft Word"
tell application "System Events"
keystroke "v" using {command down}
end tell

end tell

You could, of course, convert much of this script into Automator or other macro environment.

Another way of accomplishing this for Word would be to have the script set the Font info for the current selection point in Word, strip any style data from the clipboard, then Paste and Match Style the text into Word.

* Note: I would suggest that the best practice for writing in Word is to use Styles to format the document, not direct formatting. You could have a script environment that pasted a text and then selected that text and then set the style for that text using VBA or Applescript.

January 12, 2016

Taming the Symbols in Accordance

In the latest release of Accordance Bible software, one of the new features is the addition of Highlight Symbols. These function identically to previous word highlighting, but place instead symbols below words you attach them to. The image set that comes included in Accordance is clearly intended to be kid friendly (fun?). As a result, the color choices are not unified and lack any consistent style. So, if you find the image palette rather unpalatable, just alter them.
To find the resource folder of the images:

  1. Right-click or Control-click on the Accordance application icon in a Finder window.
  2. Select "Show Package Contents"
  3. Navigate to /Contents/Resources/  where you will see a "watermarks' folder with images 1 thru 130.
  4. Backup that folder elsewhere to be safe.
  5. Quit Accordance and have fun editing the images.

You can download a set of updated images that you see in this post. They add a consistent bluish-greyish color theme on top of Accordance's default images. You can install them by dragging the icons into the watermarks folder you navigated to. The images are available here.

Note: Here's an example of doing the same kind of thing in Dropbox, altering images in the application bundle to customize your look.