html - 在 AppleScript 和 BBEdit 中如何检查链接?

标签 html file applescript bbedit

在 BBEdit 中,Markup -> Check -> Document Links 快捷方式下有命令 cmd+control+k 检查所有链接。当我查看 BBEdit > HTML Scripting -> check links 下的字典时,它显示:

enter image description here

但是当我尝试使用以下内容针对项目编写脚本时:

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/

相关文章:

javascript - 使用 HTML 和 Javascript 进行加/减运算

java - Android:无法读取用户使用 URI 中的 getString() 和 getPath() 选择的 PDF 文件

applescript - 如何使用 AppleScript 将对象记录到控制台

javascript - 尝试创建一个准时更新功能

php - 在 jquery 函数中使用 HTML/PHP 代码

c# - 如何避免包含文件的完整路径

swift - 将包含多个文件路径的 Swift 字符串转换为 AppleScript 列表

objective-c - 在 OS X 上利用单独应用程序的资源

html - 具有未定义列数的网格布局

c++ - 如何从文件中读取 "uneven"矩阵,并存储到二维数组中?