Van Maanen Hans van Maanen

klikklikklikklik

PopClip Extensions

PopClip, by PilotMoon Software, is indispensable for anyone editing text on the Macintosh - writers, journalists, bloggers... editors... It started out as a simple emulation of the Cut-Copy-Paste popup that Apple used for the iOS, but thanks to its scripting capabilities it has developed into a very powerful tool that can perform more or less any editing task you throw at it, with any selected text.

I've written a few extensions that were rather useful while I was converting plain text or rtf files into LaTeX for a new book. After preparing the chapters with some simple macros in Nisus to code \section headings and \labels, this still left me with re-encoding the italics and the bolds into \emph and \textbf, assigning words for the \index, converting - to \textminus, and other odd jobs.
So, I thought I'd teach myself a bit of Ruby, looked at what other people had done, and whipped together a few extensions for my editing work. I thought other people might like them, too, so here they are. We assume environments etc. have all been dealt with in earlier stages of the editing process, these quickies are for the final touches.
The first one, 'Reverse', is for general text editing, the other ones are specifically for preparing LaTex documents. And I've made a multi-language Wiki extension, too.


There is a pdf-version of this page.
SwapCase 'Reverse' is actually a dual-purpose extension: capitalizing and swapping.
• First of all, it capitalizes lowercase characters and words, ash becomes Ash, and lowercases capitalized words: Ash to ash. If the selection is two or more words, as in book titles ('title case'), only the first character of the selection will be a capital, the rest is uncapitalized.
• With the option (alt) key down, the selection is converted to lowercase: ASH to ash
• With the command key, the selection is converted to capitals: ash to ASH
• If the selection is two characters and you hold down control, the two characters will be swapped: As becomes sA, and teh becomes the.

Formatter '\em' is for italics and bolds.
• Without any modifier key, it emphasizes the selection: cat becomes \emph{cat}
• With option, it goes for the italic: cat becomes \textit{cat}
• With command, the cat becomes bold: \textbf{cat}
• With option-command, we obviously get \textbf{\textit{cat}}.
• And with control, the styles will be removed and the \emph{cat} and the \textbf{cat} return to cat. Remember to include the commands in the selection, or nothing much happens...
tt '\tt' is for typewriter and smallcaps and the like, which I use less frequently.
• Without a modifier, it gives the typewriter font: foo becomes \texttt{foo}
• With option, it makes small capitals: foo becomes \textsc{foo}
• With command, the text goes sans-serif: foo will be \textsf{foo}. • With option-command, the text will be verbatim: foo will be \verb+foo+.
Mathstuff '$$' is for some simple math stuff.
• The default is to enclose the selection with dollar signs: bar becomes $ bar $
• With option, it goes for real math: bar becomes \[ bar \]
• If the selection is just a hyphen, '$$' will turn it into a minus sign: - becomes \textminus\. Hold down option to suppress the final \
• If the selection is a single x, it will turn it into a multiplication sign: x becomes \times\. Again, option removes the final \
• Elseif, if the selection is a single character not - or x, it will be italicized, like so: a becomes \textit{a}. No \textit{x}? No \textit{x}. Well, okay, try the command key.
Indexing '\ix' is for indexing.
• Without a modifier, it just indexes the selection: Joe as Joe\index{Joe}
With modifiers, the entries will be formatted for names. This is still a bit experimental, since everybody wants to index names in different ways. These options are geared to what most Dutch seem to expect...
• With option, Joe C. Doe becomes Joe C. Doe\index{Doe, Joe C.} and Dan de Man becomes Dan de Man\index{Man, Dan de}
• With command, the index will be without any middle initials or prefixes: Joe B. C. Doe becomes Joe B. C. Doe\index{Doe, Joe}. Dan de Man becomes Dan de Man\index{Man, Dan}
• With option-command, Joe B. C. Doe becomes Joe B. C. Doe\index{Doe, J. B. C.} and Dan W. de Man becomes Dan W. de Man\index{Man, D. W. de}. Note the spaces.
• And finally, with control, it's all up to you: Joe B. Doe becomes \ix{Joe B. Doe} so you can write your own '\newcommand{\ix}[1]' and handle the argument as you see fit (maybe with xparse).

tt 'Wikis' is for looking up things in different-language Wikipedias. When you install it, you'll be presented with two text boxes. Fill in your own Wikipedia language code in the upper box (just type 'de', 'fr', 'it', 'sv' ...) and your second favourite in the other one (for instance, if you read a lot of English or scientific texts, 'en'). Now when you want to search Wikipedia for a selection, if you do nothing you get your 'local' Wikipedia, if you hold down the option key, the alternate Wikipedia pages will be searched. If you prefer a different configuration, that's okay, too, of course. (Actually, you have three Wikipedias to choose from: if you hold down any other modifier key or combo, the search defaults to 'en'.)
The extension assumes you know enough about Wikipedia to fill in the proper code for you favourite languages, but you'll find out soon enough if you've entered a non-existing Wiki. Go through the options again.