且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JavaScript正则表达式修复不替换图片网址

更新时间:2023-12-05 13:56:10

使用 Autolinker.js ,它被认为是可靠的链接。

Use Autolinker.js, it is known to be reliable with linkifying.

请参阅关于其他标签/属性内部链接的说明部分:

See the description part about links inside other tags/attributes:


将正确处理HTML输入。实用程序不会改变锚点(< a> )标记内的 href 属性(或任何其他标记/属性),并且不会意外地用新标签包装锚标签的内部文本(这会导致双重嵌套的锚标签)。

Will properly handle HTML input. The utility will not change the href attribute inside anchor (<a>) tags (or any other tag/attribute for that matter), and will not accidentally wrap the inner text of an anchor tag with a new one (which would cause doubly-nested anchor tags).

以下是一个使用它的例子:

Here is an example of using it:

var linkedText = Autolinker.link(input_html, { className: "myLink" } );