Hi Eros9. This is indeed very interesting, and potentially very helpful for 
a different thing I'm trying to do.
But I don't understand HOW you run the AppleScript in the context of a Text 
Factory. In the user guide the only mention I see of AS in relation to a TF 
is the "Run AppleScript Filter" option,  which is documented as shown 
below. I'm kind of thrown off by the statement "This entry point should 
return the file’s contents as a Unicode string." Is this what you're using?

When you use the Run AppleScript Filter operation, your script should be 
written with an entry point named “ApplyTextTransform”. The input parameter 
to this entry point is a Unicode string containing the file’s contents. 
This entry point should return the file’s contents as a Unicode string (or 
something which can be directly coerced to one):
        on ApplyTextTransform (fileData)
        -- do something to fileData
        return fileData -- or some reasonable facsimile thereof
        end

On Thursday, November 2, 2023 at 10:30:49 AM UTC-7 Eros9 wrote:

This may be helpful to somebody. I have a text factory that is a chain of 
"Replace All" commands to create an html proof of an xml file. I wanted to 
add the file name to the proof, because it is crucial for correct 
processing of the xml (when it's uploaded to the system in question). 
Here's the Applescript, which is run at the start of the text factory:

on ApplyTextTransform(htmlTitle)
tell application "BBEdit"
activate
set fileName to (name of document 1) as text
set fileCont to (contents of document 1) as text
return ("<html>
<head>
<title>" & fileName & "</title>
</head>
" & fileCont)
end tell
end ApplyTextTransform

Then a grep replace command in the text factory finds the fileName and adds 
it as part of the html body as well. (I realize that the htmlTitle variable 
in the script is superfluous.)

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" 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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/b06ddb16-6d3b-4c2d-9123-3b88b9931f48n%40googlegroups.com.

Reply via email to