简体   繁体   English

我有一个 HTML 文档,其中包含一堆未格式化的链接。 有没有办法<a>在标记中自动添加标签?</a>

[英]I have an HTML doc with a bunch of links that are not formatted. Is there a way to automatically add <a> tags in the markup?

I am using Visual Studio Code and Atom.我正在使用 Visual Studio Code 和 Atom。 Is there any ability to highlight the text and add a tag to it automatically?是否有任何能力突出显示文本并自动为其添加标签?

Basically I want to generate links based on text that I have in the HTML.基本上我想根据 HTML 中的文本生成链接。 For example I have a bunch of different text like https://www.example.com in my HTML document without any tags..例如,我的 HTML 文档中有一堆不同的文本,例如https://www.example.com没有任何标签。

How can I add and output <a href="https://www.example.com">https://www.example.com</a> in the editor automatically.如何在编辑器中自动添加 output <a href="https://www.example.com">https://www.example.com</a> I have text without links and I want to add links to them automatically in the editor.我有没有链接的文本,我想在编辑器中自动添加链接。

Can you do this in the editor or do you have to use JavaScript and then copy and paste the output back into the editor?您可以在编辑器中执行此操作,还是必须使用 JavaScript 然后将 output 复制并粘贴回编辑器? Should I try regexr?我应该尝试正则表达式吗?

You can try to use the find an replace function of your editor.您可以尝试使用编辑器的查找替换 function。 I am assuming you are using an editor that has this functionality.我假设您正在使用具有此功能的编辑器。

For Visual Studio Code, this can be done by pressing command + f or ctrl + f on windows.对于 Visual Studio Code,这可以通过在 windows 上按command + fctrl + f来完成。

在此处输入图像描述

So you find the link, for example, I used https://stackoverflow.com and replaced it with <a href="https://stackoverflow.com">link</a> .所以你找到了链接,例如,我使用了 https://stackoverflow.com并将其替换为<a href="https://stackoverflow.com">link</a>

Nut you have to be careful doing this so as to not replace what you don't intend replacing.但是,您必须小心这样做,以免更换您不打算更换的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM