I painstakingly recorded a long series of text replacements to polish an export dump into a decently slick html document. I haven’t used it in a while, and now it’s doing nothing, so something’s changed in BBEdit and/or in Sequia. Can anyone spot an obvious problem?
tell application "BBEdit"
activate
replace "<a href=\"javascript:share\\(\\d+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "<a href=\"javascript:share\\(\\d.+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "<span class=\"style1\"><b>Director:</b>" using "<BR><span class=\"style1\"><b>Director:</b>" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "<b><a href=\"" using "<a href=\"" searching in text 1 of text document 1 options {starting at top:true}
replace "()" using "" searching in text 1 of text document 1 options {starting at top:true}
replace "Special Features" using "<BR><BR>Special Features" searching in text 1 of text document 1 options {starting at top:true}
replace " <b>(.+?):</b>\\n \\n <br>\\n" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace " <b>(.+?):</b>\\n \\n <b>" using "<B>" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace " " using "" searching in text 1 of text document 1 options {starting at top:true}
replace " <b>(.+?):</b>\\n \\n <b>" using "<B>" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "<b>(.+?):</b>\\n \\n <br>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "<b>(.+?):</b>\\n \\n <br>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "<b>(.+?):</b>\\n \\n \\n <br>" using "" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
replace "nk\">\\n (.+?) \\n </a>\\n <BR><span" using "nk\">\\n \\1 \\n </a>\\n <BR><BR><span" searching in text 1 of text document 1 options {search mode:grep, starting at top:true}
save text document 1
end tell
replace "Special Features" using "<BR><BR>Special Features" searching in text 1 of text document 1 options {starting at top:true}
also, near the end of each line you have
searching in text 1 of text document 1
There is no need to put a number after ‘text’
like so…
searching in text of text document 1
Here is the modified one…
tell application "BBEdit"
replace "<a href=\"javascript:share\\(\\d+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "<a href=\"javascript:share\\(\\d.+?\\);\"><img src=\"sharing/addlibrary.png\" title=\"Add to my Library\"></a></b></p>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "<span class=\"style1\"><b>Director:</b>" using "<BR><span class=\"style1\"><b>Director:</b>" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "<b><a href=\"" using "<a href=\"" searching in text of text document 1 options {starting at top:true}
replace "()" using "" searching in text of text document 1 options {starting at top:true}
replace "Special Features" using "<BR><BR>Special Features" searching in text of text document 1 options {starting at top:true}
replace " <b>(.+?):</b>\\n \\n <br>\\n" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace " <b>(.+?):</b>\\n \\n <b>" using "<B>" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace " " using "" searching in text of text document 1 options {starting at top:true}
replace " <b>(.+?):</b>\\n \\n <b>" using "<B>" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "<b>(.+?):</b>\\n \\n <br>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "<b>(.+?):</b>\\n \\n <br>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "<b>(.+?):</b>\\n \\n \\n <br>" using "" searching in text of text document 1 options {search mode:grep, starting at top:true}
replace "nk\">\\n (.+?) \\n </a>\\n <BR><span" using "nk\">\\n \\1 \\n </a>\\n <BR><BR><span" searching in text of text document 1 options {search mode:grep, starting at top:true}
save text document 1
end tell
Yeah, it’s weird. It’s an export from an app I have not upgraded in years, so it should be exporting per usual. I’d figured that Sequoia had broken some of my code, but, yeah, going through the doc, it’s…not that!
The good part is that while I remember this AppleScript doing a ton of work, it’s not really so extensive, and I just did a manual clean-up of the doc on my own. No biggie.
So to quote Iris DeMent, I’ll just “Let The Mystery Be”