I got it. I don't know why this works, but I put the normalize command 
inside a try/catch loop in hopes of getting better debugging information. 
It ran fine. I deleted the catch and it still ran as expected. At this 
point, I'm claiming the win.

```
tell application "Safari"
set sourceCode to source of document 1
end tell

tell application "BBEdit"
activate
make new text window with properties {contents:sourceCode, source 
language:"HTML"}
select insertion point before character 1 of text window 1
optimize
format mode gentle hierarchical with normalizing tag case
try
normalize line endings of text window 1
end try
copy time of (current date) to latest
save text document 1 to file ("Macintosh HD:Users:greg:Desktop:tossme-" & 
latest & ".html")
end tell
```

On Sunday, October 11, 2020 at 5:41:31 AM UTC-7 Greg Raven wrote:

> Here's another data point:
>
> If I add this script to an Automator workflow (as Run AppleScript), I can 
> then drag in the BBEdit Automator action Normalize Line Breaks (yes, 
> "breaks" and not "endings"), and it works.
>
> However, it does not work to change the main script itself from 
> "normalize" to "normalizing", nor from "endings" to "breaks".
>
> On Sunday, October 11, 2020 at 5:09:30 AM UTC-7 Greg Raven wrote:
>
>> Actually, this isn't working for me either. This is what I have so far:
>>
>> ```
>> tell application "Safari"
>> set sourceCode to source of first document
>> end tell
>>
>> tell application "BBEdit"
>> activate
>> make new text window with properties {contents:sourceCode, source 
>> language:"HTML"}
>> optimize
>> # normalize line endings
>> format mode gentle hierarchical with normalizing tag case
>> copy time of (current date) to latest
>> save text document 1 to file ("Macintosh HD:Users:greg:Desktop:tossme-" & 
>> latest & ".html")
>> end tell
>> ```
>> The "normalize line endings" command is commented out because it throws 
>> an error so the script does not run to completion. I tried wrapping it in 
>> it's own tell block, but I'm still missing something.
>>
>> On Sunday, October 11, 2020 at 4:46:59 AM UTC-7 Greg Raven wrote:
>>
>>> Ah, so. Thank you! It never occurred to me that I needed a nested tell 
>>> block.
>>>
>>> On Sunday, October 11, 2020 at 12:53:16 AM UTC-7 jj wrote:
>>>
>>>> Hi Greg,
>>>>
>>>> Here is a script that might do what you want
>>>>
>>>> tell application "Safari"
>>>> set vContents to source of first document
>>>> set vName to name of first document
>>>> end tell
>>>>
>>>> tell application "BBEdit"
>>>> tell first window
>>>> set vDocument to make new document at beginning with properties 
>>>> {name:vName, contents:vContents}
>>>> tell vDocument
>>>> normalize line endings
>>>> format mode no reorganization with normalizing tag case
>>>> end tell
>>>> end tell
>>>> end tell
>>>>
>>>> Best regards,
>>>>
>>>> Jean Jourdain
>>>>
>>>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/c15d0d3e-106b-4015-81eb-44d6a77ef01en%40googlegroups.com.

Reply via email to