Skip to main content

Markdown-URL-to-Title

本工具的功能为:自动提取剪贴板中的 URL ,然后使用 requests 获取目标 URL 的标题,根据标题生成可直接粘贴的 Markdown 内容。

背景

在使用 Hexo 写博客的时候,想给博文里插入一些参考文献,但是如果直接粘贴 URL 的话, 有的参考链接的 URL 非常长,而且会被 URL 编码,不太容易阅读,如下:

## 参考文献
* https://vi.stackexchange.com/questions/14114/paste-link-to-image-in-clipboard-when-editing-markdown
* https://c.m.163.com/news/a/FJ8PBOJ000097U7R.html?spss=adap_pc&referFrom=&spssid=592b2c22f7c667bdd783e7ef59625b86&spsw=1&isFromH5Share=article

所以就想着能不能为 Hexo 实现一个自动将 URL 转为 Markdown 带有标题文本的格式,也就是如下:

## 参考文献
* [Paste link to image in clipboard when editing Markdown - Vi and Vim Stack Exchange](https://vi.stackexchange.com/questions/14114/paste-link-to-image-in-clipboard-when-editing-markdown)
* [继微信封禁WeTool后 腾讯或大规模封禁第三方QQ机器人](https://c.m.163.com/news/a/FJ8PBOJ000097U7R.html?spss=adap_pc&referFrom=&spssid=592b2c22f7c667bdd783e7ef59625b86&spsw=1&isFromH5Share=article)

经过一番搜索暂时没有找到解决方案,没有办法,只好出此下策,使用 Python 来对剪切板进行操作,提取剪切板中的 URL 并转换为 Markdown 的格式。

环境需求

  • Windows 10
  • Python 3

例子

剪切板输入

...
https://baidu.com/
...

剪切板输出

...
[百度一下,你就知道](https://www.baidu.com/)
...

安装

通过 PyPi

pip install u2t

通过 GitHub

git clone https://github.com/WangYihang/Markdown-URL-to-Title

使用方式

  1. 打开终端,运行:u2t,此时系统托盘出现图标
  2. 复制待处理文本,不用特别精确地只复制 URL,本程序使用正则提取剪切板内容中的所有 URL 并进行批量处理
  3. 按快捷键 Ctrl + Shift + Q
  4. 等待数秒,待 Windows 弹出 Toast 提示框,即可直接进行粘贴

Release files for u2t 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for u2t 1.0.3
File Size Uploaded
u2t-1.0.3.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for u2t 1.0.3
File Interpreter ABI Platform
u2t-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / u2t-1.0.3.tar.gz

Download URL u2t-1.0.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
775e650cfc06a5979157e344bb85fa43a0660102368e41afdd199854ca9a008e
BLAKE2b-256 checksum
How to use checksums
d8818b4555804330a46d9987b2e36d8ddfc044f5a10f975e122edeba24cc147d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

Release files / u2t-1.0.3-py3-none-any.whl

Download URL u2t-1.0.3-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ebcb920a2c8b5511960a3ed3a2c23f2f2d3b97d9fa0fd6bdc2771a7f84eabb0
BLAKE2b-256 checksum
How to use checksums
e85ff45c355b3b5ef2c449684fbe4b453230c6d492caae1f3446bc3da0fc1d55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page