使用perl将html转换为文本

smi*_*ith 5 perl cpan

我有一堆html文件,需要转换并将它们格式化为带有perl的文本,即类似于<br/>将要插入的文本\n

我在cpan html :: formattext上找到了这个perl模块,它很好地格式化了文本但是如果有链接它会剥离它,是否有任何选项使用HTML :: FormatText来格式化html,就像文本一样但当有这样的链接时

<a href="http://www.microsoft.com>http://www.microsoft.com</a>
Run Code Online (Sandbox Code Playgroud)

即这样的事情:

<br /><b>Microsoft</b><br /><a href="http://www.microsoft.com>`
Run Code Online (Sandbox Code Playgroud)

将被转换为:

microsoft
http://www.microsoft.com
Run Code Online (Sandbox Code Playgroud)

Bor*_*din 7

看看HTML :: FormatText :: WithLinks

after_link选项设置为"(%l)"将使链接在锚文本之后排成一行.在你的例子中你会得到Microsoft (http://www.microsoft.com).