Blogging from BBEdit again
March 17, 2021 at 11:26 PM by Dr. Drang
A few days ago, I mentioned on Twitter that my last post was the first one I’ve written on and published from a Mac in over three years.1 I had switched to blogging from an iPad through a combination of Drafts and Shortcuts for a few reasons:
- I was trying to learn the best ways to use an iPad, and forcing myself to use it for blogging seemed like a good way to learn.
- My older son’s laptop had crapped out on him, and I gave him my MacBook Air as a stopgap until we got him a new computer.
- I was wondering if I’d ever use a Mac notebook again, as Apple was in the middle of a five-year period in which it seemed determined to ruin its most popular line of computers.
I’m going to write soon about how and why I decided to move back to the Mac for most of my work (the M1 is a big part of the story, of course, but not the whole story), but for now I want to go over how I’ve organized the tools I use for writing and publishing this blog from a Mac.
It starts with BBEdit, the Mac-assed text editor that has lots of great editing tools built in and, at least as important, allows you to build your own tools to extend it. Back when I was blogging regularly from BBEdit, I had written several scripts to make blogging easier. Over the past couple of weeks, I resurrected those scripts and added to them, stealing several ideas I used in Drafts and Shortcuts.
What I have now is a new and improved Blogging package that combines scripts written in Bash, Python, Perl, and AppleScript. The AppleScripts are all accessible from the Scripts menu (the one that looks like a scroll).
These all add text to the document I’m working on.
- turns the currently selected text into a Markdown link to Safari’s frontmost web page. It doesn’t activate Safari or force me to copy the URL—all the Safari work happens in the background.
- turns the currently selected text into a Markdown link to a web page that I’ve already linked to. It presents a list of all the links in the current document and asks me to choose one. I should change the name of this one to .
- turns the currently selected test into a Markdown link to one of the tabs in Safari. It presents a list of all the Safari tabs and asks me to choose one. This should be called .
- inserts a Markdown footnote at the current cursor position and repositions the cursor for me to write the footnote text.
- assumes the frontmost page in Safari is a page here on ANIAT. It goes to the server, grabs the Markdown source of that page, and opens a new BBEdit document with that text in it. This is mainly for when readers find an error in a post that I have to correct.
- is similar to , but doesn’t use Safari. It pulls out the Markdown source of my most recent post.
<img>
tag at the cursor position, filling in thesrc
,alt
, andtitle
attributes from the clipboard.
inserts an - gets the contents of the frontmost Numbers spreadsheet, converts it into a Markdown table, and inserts it.
Many of the scripts in the Blogging package are Text Filters. These are shell, Python, or Perl scripts that work on either the selected text or the entire document.
- does pretty much what you’d expect. When I paste a script into a blog post, it numbers the lines and formats them.
- takes selected text that I’ve copied and pasted from a spreadsheet and formats it as a Markdown table.
- clean up a messy Markdown table. adds spaces to
- cleans up the post’s metadata, which is in the top 4–5 lines of the document.
- opens a local preview in Safari so I can see how the post will look when it’s published.
- does what you think.
One of the things I don’t like about BBEdit’s package system is that scripts and text filters from the same package don’t appear together. Scripts are in the scripts menu (or palette), and text filters are in the Keyboard Maestro can handle that.
menu (or palette). ButI created a Blogging macro group in Keyboard Maestro, with simple macros that select the various menu items from the Blogging package. The macros in this group appear in a KM palette whose appearance is toggled by ⌃⌥⌘B.
The items in the palette are grouped by function.
As I said, some of the scripts behind these commands are old ones that I just haven’t used in a while. Some have been rewritten in the past couple of weeks to make them cleaner or add feature. Some are brand new to account for the changes I made a couple of years ago to the blog’s internal organization. Many of the scripts, I think, would be of no use to anyone but me. I’ll write about those that may be more broadly useful after I’ve lived with them for a while and shaken out the bugs.