michael-mccracken.net

Quick n’ Dirty OmniOutliner to MediaWiki Applescript

The other day, I had a big outline on a wiki that I wanted to edit in OmniOutliner so I could hide and move things around with a real outliner, then export it back out to the wiki.

I managed to get it into OO with copy and paste and a lot of RSI-inducing tabbing, but the text export options can’t be massaged to export MediaWiki-style (eg, ‘#’ for level one, ‘##’ for level two).

So I wrote a quick Applescript to get the data out and get me back on my way. I thought I’d post it in case it would be useful to anyone else:

tell front document of application "OmniOutliner Professional"
    
    set expText to ""
    
    repeat with aRow in rows
        set rowText to ""
        -- start from 2 to treat top levels as headers
        repeat with i from 2 to level of aRow
            set rowText to rowText & "#"
        end repeat
        set rowText to rowText & " " & topic of aRow
        set expText to expText & return & rowText
    end repeat
    
    set the clipboard to expText
    
    display dialog "The exported text is in the clipboard."
end tell

Update: see the comments for a version for TWiki. Thanks, Peter!

Comments:
  1. Peter
    March 13th, 2007 | 11:18 am

    Modified to do twiki!

    tell front document of application “OmniOutliner Professional”

    set expText to ""
    
    repeat with aRow in rows
        set rowText to ""
        -- start from 2 to treat top levels as headers
        repeat with i from 2 to level of aRow
            set rowText to rowText & "   "
        end repeat
        set rowText to rowText & "   * " & topic of aRow
        set expText to expText & return & rowText
    end repeat
    
    set the clipboard to expText
    
    display dialog "The exported text is in the clipboard."
    

    end tell

  2. March 24th, 2007 | 8:42 pm

    Michael — and Peter — thanks! This worked like a champ to pull dozens of user stories I did in OOP to Twiki. huge.

  3. September 6th, 2007 | 6:53 pm

    Hey Michael, this script was a godsend and works perfectly. Do you know if there’s a way to perform this the other way around? Copying the MediaWiki text into OmniOutliner and then do a find/replace turning the “#” characters into indents? Thanks so much! Mike

  4. September 7th, 2007 | 8:59 am

    Michael, what I do is replace ‘#’ with tab in an editor - control-Q <tab> will insert a literal tab in the ‘replace’ text field, and you’ll get what you want. Then import that text into OO…

  5. September 7th, 2007 | 1:18 pm

    Hey Mike, thanks for the tip. What text editor are you using? I did what you said in TextEdit but when I copied the resulting text, each tab created a new column in OmniOutliner. I did get it working using Word, though. I just had to replace with “^t” which is the tab character for Word.

  6. brook
    October 22nd, 2007 | 1:32 am

    thanks, this script is helpful

Leave a reply

Feed, Endorsements & other Links

my bookmarks

© 2005 - 2007 Michael McCracken.