The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Merge Children to notes field Thread Tools Search this Thread Display Modes
If the target is MarkDown, this slightly fuller version also tries to capture any *italic* or **bold** sequences in the topics/notes and represent them with Markdown asterisk emphases:

Code:
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
-- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-- IF YOU *REALLY* WANT TO DELETE THE CHILD NOTES AFTER CAPTURING THEIR TEXT
-- CHANGE THE VALUE OF THIS PROPERTY TO TRUE 
-- BUT *ONLY* EXPERIMENT WITH DISPOSABLE COPIES OF MULTIPLY BACKED UP WORK ...

property pVer : "002"

property pblnReallyDeleteDescendants : false

tell application id "OOut"
	set lstDocs to documents
	if length of lstDocs < 1 then return
	
	tell first item of lstDocs
		set lstSeln to selected rows
		if length of lstSeln < 1 then return
		tell first item of lstSeln
			if has subtopics then
				set its note to my MDEmphasis({text, font} of attribute runs of its note) & return & 
					return & my GetSubText(its children)
			end if
			set its note expanded to true
		end tell
	end tell
end tell

on GetSubText(lstChiln)
	tell application id "OOut"
		set str to ""
		-- CAPTURE THE TEXT
		repeat with oChild in lstChiln
			tell oChild
				set str to str & my MDEmphasis({text, font} of attribute runs of its topic) & 
					return & return & my MDEmphasis({text, font} of attribute runs of its note) & return & return
				if has subtopics of it then set str to str & my GetSubText(its children)
			end tell
		end repeat
		
		-- AND THEN DELETE THE CHILDREN ? 
		if pblnReallyDeleteDescendants then
			repeat with i from length of lstChiln to 1 by -1
				delete item i of lstChiln
			end repeat
		end if
		return str
	end tell
end GetSubText

on MDEmphasis({lstText, lstFont})
	set str to ""
	repeat with i from 1 to length of lstText
		set strText to item i of lstText
		if strText ≠ "" then
			set strFont to item i of lstFont
			if strFont contains "BoldOblique" or strFont contains "BoldItalic" then
				set str to str & my emphasize(strText, "***")
			else if strFont contains "bold" then
				set str to str & my emphasize(strText, "**")
			else if strFont contains "oblique" or strFont contains "italic" then
				set str to str & my emphasize(strText, "*")
			else
				set str to str & strText
			end if
		end if
	end repeat
	return str
end MDEmphasis

-- wrap the trimmed part of the string with MD emphasis markers
-- and restore the end spaces
on emphasize(strText, strMarker)
	set {dlm, my text item delimiters} to {my text item delimiters, space}
	set lstParts to text items of strText
	set lngParts to length of lstParts
	-- The opening marker
	repeat with i from 1 to lngParts
		set strPart to item i of lstParts
		if strPart ≠ "" then
			set item i of lstParts to strMarker & strPart
			exit repeat
		end if
	end repeat
	-- and the closing marker
	repeat with i from lngParts to 1 by -1
		set strPart to item i of lstParts
		if strPart ≠ "" then
			set item i of lstParts to strPart & strMarker
			exit repeat
		end if
	end repeat
	set str to lstParts as string
	set my text item delimiters to dlm
	return str
end emphasize
 
Thanks a bunch, Rob. Your script is just awesome.

You really made my day!

How can I ever repay you?
Can I sponsor you a few beer via Paypal?
 
Good ! I'm glad that worked.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Notes Field Grewal69 OmniFocus 1 for Mac 0 2013-02-08 10:02 PM
Bullets in Notes Field mctheriot OmniFocus 1 for Mac 3 2010-11-14 04:29 PM
Keep Notes field Expanded? Machineman OmniPlan General 4 2010-01-21 02:19 PM
Tabbing to Notes field Indivio OmniFocus 1 for Mac 4 2009-08-15 04:30 PM
CSV Export Notes Field Blatchara OmniFocus 1 for Mac 0 2007-12-21 10:09 AM


All times are GMT -8. The time now is 01:55 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.