2

在 BBEdit 中,快捷方式 ++ 下的命令可以Markup -> Check -> Document Links检查cmd所有链接。当我查看它下面的字典时,它显示:controlkBBEdit > 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

当我通过谷歌搜索时,我无法找到一个解决方案,即是否可以返回一个布尔值,即 HTML 文件中的链接在通过内容编写脚本时是否有效。所以我的问题是,我怎样才能让 AppleScript 告诉我链接在 BBEdit 中有效check links

4

2 回答 2

1

要检查活动文档文件中的链接:

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

资料:

set projectPath to file of project document 1, 此命令返回项目的路径(检查此文件上的链接将始终返回一个空列表),路径将为file "fullpath:someName.bbprojectd",它不是项目中所选HTML文件的路径。

获取项目所有文件的路径:set allFilePaths to project collections of project document 1 -- list of paths

于 2017-04-22T04:40:59.667 回答
1

我相信这在我上次使用它时有效,我在移动设备上即将登机,所以语法可能会变得含糊不清。

set theFile to ((path to documents folder) as string) & "test.html"
set theResult to check links of file theFile

要使用系统事件来按键,您可以使用单独的 tell 块,或者像这样创建一个处理程序。

on checkLinks()
    tell application "System Events"
        keystroke "k" using {command down, control down}
    end tell
end checkLinks

然后像往常一样调用处理程序

my checkLinks()
于 2017-04-11T03:04:27.600 回答