Welcome to the lab.

Web Excursions for August 26, 2015

[Tweet : ADN : nvALT]

How to survive working at home
Daniel Jalkut (one of my favorite indie devs) shares his mistakes and triumphs from over 10 years of being his own boss and working at home. I still need to figure out the keeping-up-hygiene-and-appearances part.
An iOS app that lets you create single site browsers (a la Fluid) to maintain separate cookies and local storage for various sites. Hat tip to @goldenhillsw.
How the Apple Watch Has Changed My Behavior for the Better

I now snapshot my work, look away, drink some water, walk to the kitchen to refill my cup, glance around to see if anybody needs me, and then get back to work.

This post encapsulates my own experience well.

Use Markdown in Evernote
An update (with fix) to an older Evernote-watching script from Dan Rosenstark for integration with Marked.
Pinboard Pro - Google Chrome extension for Pinboard.in
An alternative to the official Pinboard Chrome extension. It has essentially the same features, but the one thing I wanted very badly for Chrome was a shortcut for Tab Sets, and this offers it.

Write better Markdown

[Tweet : ADN : nvALT]

As John Gruber stated in his original introduction of the Markdown project:

The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

I work with many different “flavors” of Markdown that have branched off since Markdown 1.0. Some add syntax to accomplish more advanced output control, but the design goal typically remains the same.

The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

Well-formatted text is not only more readable, it’s more future-proof, and following a set of rules derived from the original spec means better portability.

The CommonMark project aims to clarify a lot of the things I’m about to mention. Its goal is stricter handling of ambiguities in the syntax, and it’s a justifiable one. The negative reactions to the idea seem primarily summed up as “you’re not my real dad.” People seemed more offended by the approach than the spec.

I’m on both sides. As a developer whose primary application is Markdown-based, at least 50% of my customer support involves explaining Markdown syntax and differences between flavors. A common knowledge of what’s standard is useful. Many users learn a syntax particular to a specific processor, and then face disappointment when their documents don’t render properly elsewhere.

However, I love that Markdown has been extended and tweaked for specific purposes, and I take a “personal responsibility” stance on the syntax. As long as users are aware of potential compatibility issues, they can decide for themselves how much of a mess to make when working with any given processor.

This post isn’t about proposing any standard or new flavors, it’s just about common sense guidelines that allow you to work with any processor.

Messes happen because some processors are more lax than others about formatting (preserving line breaks, allowing 2-space indentation, different interpretations of unescaped emphasis markers, etc.), or provide a syntax for elements which aren’t universal (e.g. centering with ~, fenced code with backticks or tildes, strikethrough characters). It’s fine to make use of the latter, as long as you’re aware of what won’t work elsewhere. Ambiguous formatting without recognizing the general rules, though, is just shooting yourself in the foot.

The following guidelines will serve writers well across any flavor of Markdown, and provide portability between them.

mdless: Better Markdown in Terminal

[Tweet : ADN : nvALT]

Here’s a side project that got out of hand.

I wanted to be able to view Markdown README files quickly and pleasantly from Terminal. More often than not, I’m working in an iTerm2 visor window, so opening any app—including a simple qlmanage -p—will make my current view slide away. Not a big deal, of course, but it seemed like it could be easier.

I created mdless for this. It’s a little utility that colorizes, cleans up, and pages Markdown documents. You can use -s SECTION to spit out just a single section of the document (use --list to show available sections).

Markdown is pretty easy to read just as a text file, but some README files are really long and have a lot of cruft that only looks good when rendered. So this tool cleans it up. It also fixes table formatting and highlights it, among other goodies.

If you have Pygments installed, fenced code blocks will be highlighted. And if you’re running the latest iTerm2 (beta), you can even view images inline.

You can install it with gem install mdless (you may need to use sudo gem install mdless depending on your setup). It’s been tested on systems with Ruby 1.9 through 2.1. It should work on non-Mac systems, but I haven’t tried it out.

mdless is a work in progress, but it’s doing everything it was supposed to do already. Check the project page for more info.

A Jekyll plugin for animated GIFs

[Tweet : ADN : nvALT]

I put together a Jekyll plugin called GifTag which turns local gif references into a styled placeholder with play/pause and preloading. This allows a page to finish loading before transferring heavy animated gifs, and adds user control as to when they start playing (as well as allowing them to stop).

In use, the syntax is simply:

{% gif path_to_gif %}

You can pass in either a path to a JPEG or PNG poster image, or the GIF path, as long as both exist. If it’s a GIF file, it will search for a JPG or PNG image with a matching path (but different extension). If neither of those are found, it can generate a poster frame for you with the ImageMagick package.

Here’s what it outputs:

<figure class="animated_gif_frame">
	<img src="/uploads/2015/08/autobook.jpg" data-source="/uploads/2015/08/autobook.gif" width="800" height="450" />

There’s some JavaScript and CSS you need to include (along with jQuery, unless you want to rewrite the click handler in something else) in order for it to work on the front end. Easy enough, though. Full details in my JekyllPlugins project on GitHub.

Web Excursions for August 19, 2015

[Tweet : ADN : nvALT]

Better BibTeX Cite As You Write
Integration for Zotero++, Scrivener, and Marked 2.
Shell Integration - iTerm2
The latest beta of iTerm2 (version 3) has some awesome new features. Nightly builds available.
Unsplash It
A service from Unsplash to generate placeholder images automatically with a simple url structure. Great photos. I think Placekitten might have broken, so this is my new go-to…
Tufte CSS
I love Tufte. This CSS, along with some basic classes and markup formatting, provides Tufte-compliant formatting for your text.
Browser Fairy
I’ve been a Choosy user for a long time, but it’s a dead project and I’ve been watching for a replacement. This is working well for handling multiple web browsers based on user rules. Hat tip to TJ Luoma at MacStories.
Take Control Books - Back To School Sale
For all your Mac learning, Take Control Books are written by some excellent authors, and until August 24th, the entire catalog is 50% off.

Marked 2.5 Sneak Peek

[Tweet : ADN : nvALT]

I’ve been heads down on a few projects for a while now, but I’m getting close to the release of the next update to Marked 2 (free to current users). There’s been a lot of refactoring, refining, and some new features I think you’ll like.

I’ve improved memory management and threading for faster rendering and statistics processing on long documents, as well as better stability for OS X 10.11 (El Capitan). You can also disable Readability and other advanced statistics generation when you don’t need it.

Markdown Quicktags lives again

[Tweet : ADN : nvALT]

I have a renewed interest in my Markdown Quicktags project. It’s a WordPress plugin that replaces the default “text” editor with an advanced Markdown editing tool.

It broke with version 4.0 of WordPress, and I let it slide for a while because I’m not using WordPress anymore. Now I’m doing some blogging on sites that do use WordPress, and I was getting back into plugin development as a result, so I figured it was time to update this one.

In addition to visual tweaks, WordPress’s default Insert Media button now works (and inserts Markdown syntax instead of HTML), and the handling of emphasis tags is cleaner (and more intelligent).

If you use the “Quote” command from the toolbar, it will now handle automatically quoting from the beginning of the current line, or for every line in a selection with smart indentation. If any of the lines in the selection are already quoted (> ), it will clear the quote syntax from the block.

If you select text and make it bold, italic, or a code span, the resulting text will remain selected and the button will change to allow you to remove the formatting. In fact, if you select any text with format characters on both sides of it, the buttons will update to allow you to toggle that formatting off.

There are a few other updates, and I’ll be adding to it as I have time. Priority number one was restoring previous functionality, which should all be there now. For more information see the project page, and you can find the plugin in the WordPress plugins repository. Updates will show up automatically in your Dashboard.

ExtraInfo+ for TaskPaper, now with Wiki Links

[Tweet : ADN : nvALT]

I published my version of Pedro Lobo’s Extra Info script for TaskPaper a couple of years ago. ExtraInfo+ is a script that reads tags such as @note and @map in my TaskPaper tasks, and the tag value creates a link to an external note, mind map, outline, or whatever I need in order to expand on the topic. I trigger it with FastScripts and my brainstorming and extra details for the currently-selected TaskPaper item open instantly.

I still use it almost every day, as it allows me to keep my coding projects in TaskPaper clean and readable, with all references, notes, and brainstorms externally linked.

I also make a lot of use of [[wiki linking]] in my notes and tasks, and then use services like nvWikiLinker to connect to notes in nvALT. I love the double bracket syntax because it’s easy to use, and works in any app I can run a service in (I do it in my OmniFocus notes, too). I decided to combine the functionality into ExtraInfo+.

I like to keep certain TaskPaper files in nvALT as well, so there’s the added bonus that when I view them in nvALT, all of the wiki links are clickable.

With the new version, you can put [[Name of the note]] anywhere in the text of a task and it will be found when you trigger ExtraInfo+. That note pops open in nvALT (or whatever note/editor app you specify as the first option). If the note doesn’t exist yet, it’s created from a template.

Also, it uses Notification Center for messages if Growl isn’t running, which is a step up from display dialog.

The new version of ExtraInfo+ is up on GitHub, and you can find usage instructions there as well. Note that there’s a new (and not-yet-documented) property called baseFolder which you can set to the common root of all configured paths. Then just use relative paths to the base in other variables.


The routine for finding the WikiLinks is really simple, and a good chunk of code to keep around if you’re still using AppleScript. It would be more fun in JavaScript, but I have a LOT of old AppleScripts around…

on findBetween(startTag, endTag, theString)
	set atid to text item delimiters
	set text item delimiters to startTag
	set _output to ""
	set textItems to text items of theString
	if (count of textItems) > 1 then
		set _right to item 2 of textItems
		set text item delimiters to endTag
		set textItems to text items of _right
		if (count of textItems) > 1 then
			set _output to item 1 of textItems as string
		end if
	end if
	set text item delimiters to atid
	return _output
end findBetween

Just pass it the left and right patterns, and it will return whatever is between them (or an empty string if not located). Example usage:

my findBetween("[[","]]",sourceText)


my findBetween("<title>","</title>",sourceText)