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

スポンサード リンク

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

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

コメントを投稿する

Want fries with that?

Open Source Projects