content: property pTitle : "Toggle double spacing"
  property pVer : "0.03"
  
  property pblnExceptB4Props : false
  
  property pstrPrePropertyBlanks : "//@type=property/preceding-sibling::@type=empty"
  property pstrNoText : "(//@type=empty union //@line matches '^\\s*$')"
  
  -- If the selection is extended toggles only selected lines
  -- Otherwise, toggles whole document
  
  -- Toggling: No blank lines ←→ one blank line after every text line 
  
  
  on run
  	tell application "FoldingText"
  		set lstDocs to documents
  		if lstDocs ≠ {} then
  			set oDoc to item 1 of lstDocs
  			tell oDoc
  				set recSeln to (read selection)
  				if (recSeln is missing value) or (|length| of (textRange of recSeln)) < 1 then
  					my ToggleAll(oDoc)
  				else
  					my ToggleSeln(oDoc, recSeln)
  				end if
  			end tell
  		end if
  	end tell
  end run
  
  on ToggleSeln(oDoc, recSeln)
  	tell application "FoldingText"
  		tell oDoc
  			set strSelnPath to (nodePath of recSeln)
  			
  			-- COUNT THE BLANKS IN THE SELECTION
  			set strBlanksPath to (strSelnPath & " intersect " & pstrNoText)
  			set lstBlanks to read nodes at path strBlanksPath
  			if lstBlanks ≠ {} then
  				-- IF THERE ARE ANY BLANKS IN THE SELCTION, REMOVE THEM ...
  				delete nodes at path strBlanksPath
  			else
  				-- IF THERE ARE NONE, SEPARATE OUT THE LINES IN THE SELECTION
  				-- (ADD A SINGLE BLANK AFTER EVERY TEXT NODE IN THE SELECTION)
  				repeat with oLine in (read nodes at path strSelnPath)
  					create nodes at id (|id| of oLine) with relation "nextLine" from text ""
  				end repeat
  				
  			end if
  		end tell
  	end tell
  end ToggleSeln
  
  on ToggleAll(oDoc)
  	tell application "FoldingText"
  		tell oDoc
  			-- COUNT BLANK LINES
  			set lstBlanks to read nodes at path pstrNoText
  			if lstBlanks ≠ {} then
  				-- IF THERE ARE ANY, THEN REMOVE ALL BLANK LINES
  				my StripBlanks(it)
  			else
  				-- IF THERE ARE NONE, SEPARATE OUT THE LINES
  				-- ADD A SINGLE BLANK AFTER EVERY EXISTING NODE
  				set strViewPath to read node path
  				repeat with oLine in (read nodes at path strViewPath)
  					create nodes at id (|id| of oLine) with relation "nextLine" from text ""
  				end repeat
  				
  				if pblnExceptB4Props then
  					-- BUT OPTIONALLY DELETE ANY BLANKS BEFORE PROPERTY LINES
  					set strNodes to (body of (read JSON (HTTP request URI "/nodes.json?path=" & pstrPrePropertyBlanks & "&attributes=id")))
  					
  					-- Feed an unquoted comma-delimited version of the list to the delete command
  					set {dlm, my text item delimiters} to {my text item delimiters, ","}
  					HTTP request method "DELETE" URI "/nodes/" & ((run script strNodes) as text)
  					set my text item delimiters to dlm
  				end if
  			end if
  		end tell
  	end tell
  end ToggleAll
  
  
  on StripBlanks(oDoc)
  	tell application "FoldingText"
  		tell oDoc
  			---- GET A COMMA-DELIMITED LIST OF THE IDS OF EMPTY NODES
  			set strNodes to (body of (read JSON (HTTP request URI "/nodes.json?path=" & pstrNoText & "&attributes=id")))
  			set {dlm, my text item delimiters} to {my text item delimiters, ","}
  			
  			-- DELETE ALL THE EMPTY NODES ...
  			-- (providing a comma-delimited list of IDs)
  			HTTP request method "DELETE" URI "/nodes/" & ((run script strNodes) as text)
  			set my text item delimiters to dlm
  		end tell
  	end tell
  end StripBlanks
  