Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staticaland/go-whaturl
Add titles to your URLs!
https://github.com/staticaland/go-whaturl
cli cue cuelang go golang markdown org-mode
Last synced: 3 months ago
JSON representation
Add titles to your URLs!
- Host: GitHub
- URL: https://github.com/staticaland/go-whaturl
- Owner: staticaland
- Created: 2022-07-28T16:36:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-05T11:50:50.000Z (5 months ago)
- Last Synced: 2024-07-27T21:19:31.083Z (3 months ago)
- Topics: cli, cue, cuelang, go, golang, markdown, org-mode
- Language: CUE
- Homepage:
- Size: 294 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
- awesome-cue - go-whaturl - whaturl replaces URLs found in text with a markup hyperlink. (Projects)
README
* whaturl
#+begin_html
#+end_html* About
=whaturl= replaces URLs found in text with a markup hyperlink with the contents
of the == tag in the HTML of the URL. It works like a typical [[https://en.wikipedia.org/wiki/Filter_%28software%29][Unix
filter]]:#+begin_src sh
echo "I like https://github.com" | whaturl
I like [GitHub: Where the world builds software · GitHub](https://github.com)
#+end_srcInspired by [[http://brettterpstra.com/2015/02/18/titler-system-service/][Titler by Brett Terpstra]] for Mac OS and [[https://github.com/rexim/org-cliplink][org-cliplink]] for Emacs.
* Installation
[[https://github.com/staticaland/go-whaturl/releases][Check out releases for pre-built binaries]].
A Homebrew formula is included at [[./Formula/whaturl.rb][Formula/whaturl.rb]].
#+begin_src sh
brew tap staticaland/go-whaturl https://github.com/staticaland/go-whaturl
brew install whaturl
#+end_srcIf you watch the project (Watch → Custom → Releases) you can easily upgrade to
the latest version when notified:#+begin_src sh
brew upgrade whaturl
#+end_srcTo uninstall:
#+begin_src sh
brew uninstall whaturl
brew untap staticaland/go-whaturl
#+end_src* Usage
#+begin_src sh :wrap src sh :results raw :exports results
whaturl --help 2>&1
#+end_src#+RESULTS:
#+begin_src sh
Usage of whaturl:
-format string
Specify link format (default "markdown")
-list
Create list of links
-relaxed
Process URLs without a schema
#+end_srcIf you run the program, it will wait for input from [[https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)][stdin]].
#+begin_src sh
whaturl
#+end_srcYou can write lines to it and get a result by pressing enter. To finish, press
Ctrl+D to communicate [[https://en.wikipedia.org/wiki/End-of-Transmission_character][end-of-transmission]]. However, the more common use-case is
to pipe something directly:#+begin_src sh
cat urls | whaturl
#+end_src* Editor integration
** Emacs
I use =reformatter.el= (see [[https://github.com/staticaland/doom-emacs-config/blob/master/modules/editor/reformatter/config.el][my reformatter.el configuration here]]). You may also
want to check out [[https://github.com/radian-software/apheleia][Apheleia]]. Otherwise, =shell-command-on-region= ([[https://www.gnu.org/software/emacs/manual/html_node/emacs/Single-Shell.html][docs]]) is what
you are looking for. Read [[https://www.masteringemacs.org/article/executing-shell-commands-emacs][Executing Shell Commands in Emacs]] to learn more.** Vim
#+begin_example
nnoremap l :%!whaturl
vnoremap l :!whaturl
#+end_exampleThis is reminiscent of the [[https://blog.sanctum.geek.nz/vim-koans/][Vim Kōan Master Wq and the Markdown acolyte]].
* Build and run
#+begin_html
#+end_html#+begin_src sh
go build whaturl.go
#+end_src#+begin_src sh
go run whaturl.go
#+end_src* Tests
#+begin_html
#+end_htmlYou can find some table driven tests in [[./whaturl_test.go][whaturl_test.go]].
#+begin_src sh
go test
#+end_src* Similar projects
- [[https://github.com/Skn0tt/markdown-link-expander][markdown-link-expander]]
- [[https://github.com/kukushi/PasteURL][kukushi/PasteURL]]
- [[https://github.com/zolrath/obsidian-auto-link-title][zolrath/obsidian-auto-link-title]]
- [[https://github.com/sindresorhus/linkify-urls][sindresorhus/linkify-urls]]
- [[https://github.com/sindresorhus/urls-md][sindresorhus/urls-md]]
- [[https://github.com/alphapapa/org-protocol-capture-html][alphapapa/org-protocol-capture-html]]
- [[https://github.com/deathau/markdownload][deathau/markdownload]]
- [[https://gist.github.com/kepano/90c05f162c37cf730abb8ff027987ca3][kepano/obsidian-web-clipper.js]]
- [[https://forum.keyboardmaestro.com/t/create-a-markdown-link-url-title-url-for-a-url-in-the-clipboard/8505][Keyboard Maestro - Create a Markdown Link for a URL in the Clipboard]]
- [[https://forum.obsidian.md/t/hyper-optimized-url-grabber-using-keyboard-maestro-on-the-mac/34318][Hyper Optimized URL grabber (Using Keyboard Maestro on the Mac)]]* See also
- [[https://benjamincongdon.me/blog/2020/06/27/Vim-Tip-Paste-Markdown-Link-with-Automatic-Title-Fetching/][Vim Tip: Paste Markdown Link with Automatic Title Fetching]]
- [[https://www.moncefbelyamani.com/automate-pasting-title-and-url-of-frontmost-browser/][Automate Copying and Pasting the Current Page Title and URL with Keyboard
Maestro]]* Bookmarklets
[[https://orgmode.org][Org Mode]]:
#+begin_src js
javascript:(
function(){
prompt(
'',
'[['
+location.href
+']['
+document.title.replace(/ [-,|].*$/,'')
+']]'
)
}
)()
#+end_srcMarkdown:
#+begin_src js
javascript:(
function(){
prompt(
'',
'['
+[location.href]()
+']('
+location.href
+')'
)
}
)()
#+end_src