在 BBEdit 中,Markup -> Check -> Document Links
快捷方式下有命令 cmd+control+k 检查所有链接。当我查看 BBEdit > HTML Scripting -> check links
下的字典时,它显示:
但是当我尝试使用以下内容针对项目编写脚本时:
set theResult to check links of active document of project window 1
当我尝试根据文件名进行检查时,出现 item
错误:
set foobar to (name of active document of project window 1) as string
set theResult to check links of foobar
如果我尝试,我仍然会遇到同样的错误:
set projectPath to file of project document 1
set theResult to check links of projectPath
我收到返回的 {}
。认为这是不添加 with show results
的问题,我将其更改为:
set theResult to check links of projectPath with show results
但是我得到了 activate
的返回
当我通过 Google 搜索时,我无法找到解决方案:在编写内容脚本时是否可以返回 bool 值,判断 HTML 文件中的链接是否有效。所以我的问题是,如何让 AppleScript 通过检查链接
告诉我链接在 BBEdit 中有效?
最佳答案
要检查事件文档的文件中的链接:
tell application "BBEdit"
set theFilePathOfFrontProject to file of text document 1 -- get the path of the selected file in the front project window
set theResult to (check links of theFilePathOfFrontProject) is {}
if theResult then
display dialog "All links appear to be valid"
else
display dialog "Some links appear to be not valid"
end if
end tell
信息:
将projectPath设置为项目文档1的文件
,此命令返回项目的路径(检查此文件上的链接将始终返回空列表),路径将为file "fullpath:someName.bbprojectd"
,它不是项目中所选 HTML 文件的路径。
获取项目所有文件的路径:将 allFilePaths 设置为项目文档 1 的项目集合 - 路径列表
关于html - 在 AppleScript 和 BBEdit 中如何检查链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43335599/