Skip to content

Instantly share code, notes, and snippets.

@bkbeachlabs
Last active August 29, 2015 14:20
Show Gist options
  • Save bkbeachlabs/b99d72ede88af8818124 to your computer and use it in GitHub Desktop.
Save bkbeachlabs/b99d72ede88af8818124 to your computer and use it in GitHub Desktop.
Rainbow Logs - Searches and Highlights paragraphs of a TextEdit document that contain a string query
-- Action 1 - Get Contents of TextEdit Document
-- |
-- V
-- Action 2 - Custom Apple Script (Below)
on run {input, parameters}
log "--------------------"
set MyColor to choose color
set FindText to the text returned of (display dialog "What string should we search for to highlight?" default answer "")
log "Finding Text:"
log FindText
log "Occurences Matching Text:"
tell application "TextEdit"
--log paragraphs of front document
set paragraphsArr to paragraphs of front document
set numParagraphs to (count of paragraphsArr)
tell me to log numParagraphs
set counter to 0
repeat with thisParagraph in paragraphsArr
--tell me to log thisParagraph
set counter to (counter + 1)
tell me to log (counter / numParagraphs)
if thisParagraph contains FindText then
tell me to log thisParagraph as text
--set color of thisParagraph to MyColor
set color of (paragraph counter of front document) to MyColor
end if
end repeat
end tell
log "--------------------"
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment