Scripts for WordPress and BBEdit, Part 3

If you write a lot of helper scripts that you come to depend on, you’ll probably come to realize how interdependent they are. They don’t all get written at once, of course, so they kind of accrete onto your working environment—written in whatever language seems the most appropriate at the time and saved wherever convenient. If, at some later time, you try to rationalize these scripts, you’ll learn just how many you’ve built up and how difficult it is to organize them into something that others can use.

That, at least, has been my experience in pulling together the scripts I’ve written for writing and publishing WordPress posts in Markdown format. The Scripts, Text Filters, and Clippings that actually appear in the BBEdit menus are themselves dependent on a raft of helper scripts and external libraries that are stored outside the BBEdit framework. Pulling everything together into a single package that can be downloaded and installed by someone else has been a chore, but I think it’s finally done. Many thanks to Patrick Woolsey, who mans the Bare Bones support email system, for walking my through some of the details of putting together a BBEdit package that aren’t covered in the manual. One day I’ll write a post about the tips I picked up from him, but this is not that day.

The package is called WP-MD and is available in this GitHub repository. The README describes each script and indicates whether the script needs customization, relies on non-standard libraries, or needs some other external configuration. You install it by downloading the WP-MD.bbpackage folder, customizing it as necessary, and dragging it into either

depending on where you keep your BBEdit extras. I use the Dropbox option to keep my iMac and MacBook Air in sync.

There’s no need to keep every item in the package. You can trim it down by deleting anything you wouldn’t use. Just don’t delete helper scripts that other scripts rely on.

Here’s the description of the package contents from the README. As you can see, even after tidying up it’s still an oddball collection of interlocking scripts written in four languages. Despite its convoluted structure, in practice it works very smoothly, especially with well-chosen keyboard shortcuts.


Resources

These are a set of helper scripts that are called by the user-facing scripts, text filters, and clippings.

bbstdin (Shell script)
A utility script that converts BBEdit text into stdin for piping to other scripts.

get-post (Python script)
Retrieve the header and text of the specified blog post and return it in stdout.

recent-posts (Python script)
Return a list of recent posts with post number and title for each.

nextreflink (Python script)
Scan text for numbered Markdown reference-style links and return the next one in the series.

getreflink (Python script)
Scan text for Markdown reference-style links, display them in a dialog box, and return the one chosen by the user.

glucky (Ruby script)
Return URL of Google’s “I’m Feeling Lucky” link for the given text.

prepend-language (Perl script)
Determine a script’s language from its shebang line (if present) and return the script with that language prepended to it.

flickroriginal (Python script)
Return an <img> link to the Original image file shown on the Flickr page in the frontmost Safari tab.

flickr640 (Python script)
Return an <img> link to the Medium 640 image file shown on the Flickr page in the frontmost Safari tab.

flickr800 (Python script)
Return an <img> link to the Medium 800 image file shown on the Flickr page in the frontmost Safari tab.

flickr1024 (Python script)
Return an <img> link to the Large image file shown on the Flickr page in the frontmost Safari tab.

Text Filters

Publish Post.py (Python script)
Takes the current window or selection and publishes it.

Line-Numbered Source Code.textfactory (BBEdit text factory)
Takes the selected lines, numbers the lines, indents it so Markdown will format it as source code, and prepends a language description if there’s a #! line.

Tabs to Markdown Table.pl (Perl script)
Takes a set of lines with tab-separated values and turns it into a MultiMarkdown-style table. Most useful when copying a table from a spreadsheet into a Markdown file.

Normalize Table.py (Python script)
Takes a MultiMarkdown-style table with ragged column separators and aligns them. Intended to be used with a non-proportional font.

Tidy Markdown Reference Links.py (Python script)
Renumbers and reorders Markdown reference links in a post.

Scripts

Get Recent Post (AppleScript)
Presents a list of the 15 most recent blog posts. Creates a new window with the selected post. Uses the get-post and recent-posts helper scripts.

New Reference Link (AppleScript)
Creates a new Markdown reference-style link, defaulting to the URL of the frontmost tab of Safari. Uses the nextreflink helper script.

Old Reference Link (AppleScript)
Creates a Markdown reference-style link to a URL already in the document. Uses the getreflink helper script.

Google Lucky Link (AppleScript)
Creates a Markdown reference style link to the “I’m Feeling Lucky” hit on the selected text. Uses the glucky helper script.

Clippings

These are kept in a Blogging subgroup and are tied to Markdown files.

Post header
Inserts a post template with fill-in spots for the title, keywords, and body. The publication date is given an initial value of two hours from the time the clipping is inserted.

Flickr original image
Inserts an <img> link for the Original image file shown on the Flickr page in the frontmost Safari tab. Uses the flickroriginal helper script.

Flickr 640 image
Inserts an <img> link for the Medium 640 image file shown on the Flickr page in the frontmost Safari tab. Uses the flickr640 helper script.

Flickr 800 image
Inserts an <img> link for the Medium 800 image file shown on the Flickr page in the frontmost Safari tab. Uses the flickr800 helper script.

Flickr 1024 image
Inserts an <img> link for the Large image file shown on the Flickr page in the frontmost Safari tab. Uses the flickr1024 helper script.


Comments are closed.