Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
Tinderbox Users >> Exporting from Tinderbox >> Nakakoji view -> Taskpaper format

Message started by Matt Cawood on Feb 15th, 2012, 12:58am

Title: Nakakoji view -> Taskpaper format
Post by Matt Cawood on Feb 15th, 2012, 12:58am

This might better belong in the "Off The Wall" section, but I'll float it here to start with. It's a suggestion born of the growing expectation that everything I do on the Mac can be readily synced to a mobile device.

Tinderbox has Simplenote sync, but Simplenote loses the outline structure, which is a fair bit of the point of Tinderbox in the first place. I'm not looking for a Tinderbox iOS app (I am, but I'm realistic), but if I could easily sync selected notes with their structure intact for reading in iOS, Tinderbox would feel less like a stranded asset.

I don't necessarily need iOS->Tinderbox sync, although I wouldn't object to it either.

So, a query. Can Nakakoji view be tweaked so that a text export can be saved as a formatted Taskpaper document, with
Projects:  = containers
- Tasks = note titles
Note Text = note text
... and any desired attributes added as @ tags?

If this was possible, I could select a group of notes, hit Opt-Cmd-N, check that Nakakoji view was using the "Taskpaper" template, and save it to Dropbox. I'd then have access to my essential Tinderbox info via Taskpaper on any other Mac, iPhone and iPad.

Does this read like something that might be possible?

Title: Re: Nakakoji view -> Taskpaper format
Post by Mark Anderson on Feb 15th, 2012, 5:34am

Perfectly possible, assuming all TB project containers are root level in your selection. If not you'll need some TB-side metadata to tell the templates which objects are projects etc.  In other words you need to capture your currently unstated assumptions about your TB layout and selection-for-export plans in order to figure out the edge cases (if any) for the export template.

The Taskpaper format isn't authoritatively documented though the rough format (based on this article) seems to be:
  • A project is any line (paragraph?) ending in a colon
  • A task is any line starting with a dash (hyphen/minus) plus a space, e.g. "- "
  • A note is any line not matching either of the above rules.
  • Tab indentation at the beginning of a line indicate nesting/ownership
  • TaskNote-searchable attributes are tagged in two differing ways: @attributename or @attributename(value)
The last two are problems to solve. For the tab indenting, you're into a little maths. For projects (containers) you want the number of tab indents to be ($OutlineDepth-1). Thus a third level project ($OutlineDepth is 3) would export indented by 2 tabs. Tasks are TB children but export in TN format at the same indent level so need to use ($OutlineDepth(parent)-1). A task note for a third level container is outline depth 4, but using the parent's data 3-1 = 1 so the exported task also gets 2 tabs.

You don't need to add colon-suffixes or hyphen-space prefixes to the $Name of your TB notes as the export can figure that out. For instance:

^if($ChildCount)^^indent("\t",($OutlineDepth -1))^^value($Name)^:^else^^indent("\t",($OutlineDepth(parent) -1))^- $Name^endIf^

A limit of the TN format is your TB task note's $Text cannot contain line breaks - i.e. it must be one paragraph (one or more sentences).

For tags/attributes, you need to figure for each TN-relevant TB attribute whether you are exporting the TB attribute name or the value or both. If you just want to export a TB Set or List attribute's value(s) as TN tags then .format() should suffice. For instance, let's assume we've a TB Set attribute $TaskNote which holds one or more TN 'attribute' values. Thus we want TB list values  "ant;bee;cow" to be exported as a text string "@ant @bee @cow". Note here another inherent TN format limitation whereby your TB attribute list values must not contain spaces. The export code for $TaskNote data might look like:

^value(if($TaskNote){" @" + $TaskNote.format(" @")})^

In order to make the export templates more modular and to allow use of ^include^ and such, you may find it more useful to use HTML Export (and HTML view for preview) rather than Nakakoji view. Which approach suits better probably depends on personal taste.

I hope that give you a few ideas.  :)

Title: Re: Nakakoji view -> Taskpaper format
Post by Matt Cawood on Feb 15th, 2012, 4:12pm

Very helpful, thanks Mark. I'll tinker and be back when I hit the inevitable meltdown.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.