AppleScript で Markdown 記法のリンクを自動挿入 (2)

AppleScript で Markdown 記法のリンクを自動挿入 (2)

2007/01/06 4:10am

AppleScript で Markdown 記法のリンクを自動挿入」のスクリプトを更に改良して、選択範囲がない場合は Web ページのタイトルをそのまま挿入するようにした。

tell first document of application "Safari"
  set pageTitle to name
  set pageURL to URL
end tell

tell first document of application "mi"
  set newText to selection as Unicode text
  if (count of newText) = 0 then
    set newText to pageTitle
  end if
  set selection to "[" & newText & "](" & pageURL & " \"" & pageTitle & "\")"
end tell

これでだいぶ楽になったな。