Skip to content

Instantly share code, notes, and snippets.

@dpk
Created October 26, 2010 09:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dpk/646570 to your computer and use it in GitHub Desktop.
Save dpk/646570 to your computer and use it in GitHub Desktop.
View Generated Source in BBEdit
-- based on John Gruber's original Safari Source in BBEdit script
-- http://daringfireball.net/2003/01/safari_source_in_bbedit
-- and duct tape
tell application "Safari" to set theSource to do JavaScript "window.document.documentElement.outerHTML" in document 1
tell application "BBEdit"
activate
make new text window with properties ¬
{contents:theSource, source language:"HTML"}
-- fix the \n that Safari sent over
replace "\\n" using "\\r" searching in text 1 of text window 1 ¬
options {search mode:grep, starting at top:true}
select insertion point before character 1 of text window 1
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment