Create markdown links from text containing URLs
Project description
marklink
marklink
replaces URLs found in text with a markup hyperlink with the contents
of the <title>
tag in the HTML of the URL. It works like a typical Unix
filter:
echo "I like https://github.com?something=what" | marklink --format md --remove-query
I like [GitHub: Where the world builds software · GitHub](https://github.com)
Its goal is to increase the ergonomics of writing, thus leading you to write more. You get to experience the joy of having robots helping you while writing.
Inspired by Titler by Brett Terpstra for Mac OS and org-cliplink for Emacs.
The ultimate goal of this project is to be cross platform and support many formats, workflows and editors.
Installation
With pip
:
pip install --user git+https://github.com/staticaland/marklink.git#egg=marklink
With pipx
:
pipx install 'git+https://github.com/staticaland/marklink.git#egg=marklink'
Editor integration
Vim
nnoremap <leader>l :%!marklink<CR>
vnoremap <leader>l :!marklink<CR>
This is reminiscent of the Vim Kōan Master Wq and the Markdown acolyte.
Emacs
I use reformatter.el
(see my reformatter.el config here).
You can also use some variant of shell-command-on-region
:
(defun marklink-org ()
(interactive *)
(save-excursion
(shell-command-on-region (mark) (point) "marklink --format org" (buffer-name) t)))
You may have to set the following if you like an exotic $SHELL
:
(setq explicit-shell-file-name "/bin/bash")
(setq shell-file-name explicit-shell-file-name)
Atom, Sublime Text, VS Code et al.
Pull requests most welcome.
You may want to consider Paste URL at the Visual Studio Marketplace.
Usage
usage: marklink [-h] [-f {md,org,html}] [-q] [files]
Args that start with '--' (eg. -f) can also be set in a config file
(~/.marklink). Config file syntax allows: key=value, flag=true, stuff=[a,b,c]
(for details, see syntax at https://goo.gl/R74nmi). If an arg is specified in
more than one place, then commandline values override config file values which
override defaults.
positional arguments:
files
optional arguments:
-h, --help show this help message and exit
-f {md,org,html}, --format {md,org,html}
which format
-q, --remove-query remove query parameters
Other alternatives
Use a bookmarklet (source):
javascript:(
function(){
prompt(
'',
'[['
+location.href
+']['
+document.title.replace(/ [-,|].*$/,'')
+']]'
)
}
)()
Some useful links:
Using external filter commands to reformat HTML
GitHub - ferrine/md-img-paste.vim: paste image to markdown
Vim Tip: Paste Markdown Link with Automatic Title Fetching | Ben Congdon
GitHub - alphapapa/org-web-tools: View, capture, and archive Web pages in Org-mode
Plans
Add to Python Package Index.
Make it faster. Do concurrent HTTP requests somehow.
Ignore files such as images.
Rewrite to golang to avoid dependencies for end users.
Set another user agent.
Change the name.
org-mode gif.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file marklink-1.1.0.tar.gz
.
File metadata
- Download URL: marklink-1.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.6 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7046a3ff1ee00fb96037a4ff37697c939868a1eb77c9f49f45f0b80a3937fbd1 |
|
MD5 | 0b62c22d1c7f682956292c239cdca5c3 |
|
BLAKE2b-256 | 9436bb0ddbed88ba58b633a0daa0909621b9a7960ff3d8a1719530a156ddefe7 |
File details
Details for the file marklink-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: marklink-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.6 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dd94492882b441fe645d30c1a02b2024f57ffd617a350b5dfe3ebc0eb4dd186 |
|
MD5 | 402a56df2c1818be625f0e7b9940c06e |
|
BLAKE2b-256 | 2cfdbcf93539277b13d52307ec7980c7240c66b82fa45872c8ced604baca7690 |