content: -- Change first selected node to heading, 
  -- or deepen level if already heading
  
  -- DEV 1.1 Script
  
  property pstrType : "heading"
  
  on run
  	tell application "FoldingText"
  		-- CHECK THAT THERE IS A DOCUMENT
  		set lstDocs to documents
  		if lstDocs ≠ {} then
  			
  			-- READ THE ID TYPE AND LEVEL OF THE SELECTION
  			tell item 1 of lstDocs
  				set recSeln to (read selection)
  				if recSeln is missing value then return
  				set lngPosn to location of textRange of recSeln
  				
  				set {strID, strType, lngLevel} to {|id|, |type|, level} of item 1 of ¬
  					(read nodes at path nodePath of (recSeln))
  				
  				-- DECIDE WHETHER TO CHANGE TYPE OR DEEPEN THE EXISTING LEVEL
  				if strType ≠ pstrType then
  					set recChanges to {|type|:pstrType}
  					if strType ≠ "unordered" then
  						if strType ≠ "ordered" then
  							set lngPosn to lngPosn + 2
  						else
  							set lngPosn to lngPosn - 1
  						end if
  					end if
  				else
  					set recChanges to {level:lngLevel + 1}
  					set lngPosn to lngPosn + 1
  				end if
  				
  				-- AND MAKE THE CHANGE
  				update nodes at ids {strID} with changes recChanges
  				
  				set location of textRange of recSeln to lngPosn
  				update selection with changes recSeln
  			end tell
  		end if
  	end tell
  end run
  