Quick n' Dirty OmniOutliner to MediaWiki Applescript
Tuesday 30 January 2007 - Filed under mac + web
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!
2007-01-30 » mike
13 March 2007 @ 11:18 am
Modified to do twiki!
tell front document of application “OmniOutliner Professional”
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
24 March 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.
6 September 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
7 September 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…
7 September 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.
22 October 2007 @ 1:32 am
thanks, this script is helpful