Wading through my GitHub repositories, checking if there was any detritus beyond the, look ma, I can fork this, type of thing, I uncovered an artifact from January 2016.

I am proud to share with you, fine readers, the Soundsmitten Outline Compiler v0.0.0.

Write JavaScript code in your favorite OPML editor (OmniOutliner, etc.). Then compile it into some squeaky-clean Standard Style JavaScript.

Inspiration comes from Brent Simmons’s post:

I wrote most of my code in an outliner for eight years (when I was working on UserLand Frontier). And I miss it every day. Writing code in an outliner is the exact opposite of horrible. It’s marvelous.

With roadmap:

  • Maybe add more languages?
  • Add in some Keyboard Maestro/JXA/Hazel/TextExpander magic to make this a feasible workflow.

This is a very nice loop:

for (var i = 0; i < lines.length; i++) {
    var line = lines[i]
    if (!line.match(/.*{/) && !line.match(/.*}/) && !line.match(/^(.*:.*)/)) {
      line = line.concat(';')
    } else if ((i < lines.length) && line.match(/.*:.*/) && i !== lines.length - 1) {
      line = line.concat(',')
    }
    if (line.match(/.*:.*/) && getLevel(line) > getLevel(line + 1)) {
      line = line.concat('}')
    }
    this.output += line
    if (i !== lines.length - 1) {
      this.output += '\n'
    }
}

getLevel(line + 1) catches the eye.

function getLevel (line) {
  var count = 0
  for (var i = 0; i < line.length; i++) {
    if (line.charAt(i) === SPACE_CHAR) {
      count += (1 / NUMBER_OF_SPACE_CHARS)
    } else {
      break
    }
  }
  return count
}

The repository remains private. Anyone near it loses brain cells.

Thanks, Brent.