Forgot password?
 Create new account
View 1067|Reply 1

将书中的 url 链接导出为 html

[Copy link]

700

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2016-7-22 17:40:52 |Read mode
闲得慌就是容易产生一些无聊的想法——刚才突然想到,能不能将《撸题集》中的众多 url 链接集中起来?

开始时想在 PDF 阅读器里入手,但在 Adobe Acrobat 里鼓捣了好一会都没成功,顶多把全部 http 搜出来,也不知怎么一次过全部复制。

想来想去,还是从源代码入手吧,既然 tex 能生成 aux、toc 这些辅助文件,那要实现我想要的东西应该没什么问题吧。

看了下 texbook 里关于读写的相关内容,果然很容易就解决了:
在正文开始前加上
  1. \newwrite\urlfile
  2. \immediate\openout\urlfile=urls.html\relax
  3. \let\oldurl\url
  4. \renewcommand\url[1]{%
  5. \immediate\write\urlfile{<p><a href="#1" target="_blank">#1</a></p>}%
  6. \oldurl{#1}}
Copy the Code
在结尾处加
  1. \immediate\closeout\urlfile
Copy the Code
(其实不加这个关闭好像也行,不过不知会不会有什么不良后果)
这样,编译之后就会生成一个包含书中全部 url 链接的 html 文件,打开还能点击的。

刚才测试生成的文件: $type urls.html (230.4 KB, Downloads: 795) ,1663 行,也就是书中共 1663 个 url 链接。

真无聊……

700

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

 Author| kuing Posted at 2016-7-22 18:04:56
接下来就可以用网页存档工具把那些网页批量保存到本地,我是存档党……

手机版Mobile version|Leisure Math Forum

2025-4-21 01:18 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list