Last active
February 1, 2021 13:40
-
-
Save Metaxal/66bfe03ea875100933fea017187c8a1c to your computer and use it in GitHub Desktop.
Copy some hyperlinked text into the clipboard, then use this script to output both the text and the url.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require quickscript | |
racket/class | |
racket/list | |
racket/gui/base) | |
;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or | |
;; [MIT license](http://opensource.org/licenses/MIT) at your option. | |
;;; The clipboard must contain a link copied from a webpage. | |
;;; The script outputs the selected text and the hyperlink. | |
(define-script clipboard->text+url | |
#:label "clipboard->text+url" | |
(λ (selection) | |
(define x (send the-clipboard get-clipboard-string 0)) | |
(define str (bytes->string/utf-8 (send the-clipboard get-clipboard-data "text/html" 0))) | |
(define link (regexp-match #px"href=\"([^\"]*)\" " str)) | |
(format "~a ~s" x (and link (second link))))) | |
(module url2script-info racket/base | |
(provide filename url) | |
(define filename "clipboard2text+url.rkt") | |
(define url "https://gist.github.com/Metaxal/66bfe03ea875100933fea017187c8a1c")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment