[英]How can I convert plain text to HTML (preferably using Perl)?
Is there a way to take a plain text file and convert it to a simple HTML? 有没有办法获取纯文本文件并将其转换为简单的HTML?
A couple of 'sophisticated' stuff that will be great 一些“复杂”的东西会很棒
UPDATE UPDATE
I just found this HTML::FromText . 我刚刚发现了这个HTML :: FromText 。 Checking to see if it meets my needs... 检查它是否符合我的需求......
Stack Overflow already uses Markdown because it's the best mark-up language targeted to general text to HTML conversion. Stack Overflow已经使用Markdown,因为它是针对一般文本到HTML转换的最佳标记语言。 Named links are explained in the editing help . 编辑帮助中解释了命名链接。
Try HTML::TextToHTML : 试试HTML :: TextToHTML :
From the command line: 从命令行:
txt2html I<arguments>
From Scripts: 来自脚本:
use HTML::TextToHTML;
# create a new object
my $conv = new HTML::TextToHTML();
# convert a file
$conv->txt2html(infile=>[$text_file],
outfile=>$html_file,
title=>"Wonderful Things",
mail=>1,
]);
# reset arguments
$conv->args(infile=>[], mail=>0);
# convert a string
$newstring = $conv->process_chunk($mystring)
You can use lynx with -dump option to achieve that: 您可以使用lynx和-dump选项来实现:
use File::Temp;
sub html2Txt {
my $html = shift;
my $html_file = File::Temp->new(SUFFIX => '.html');
print $html_file $html;
close $html_file;
return scalar `lynx -dump $html_file 2> /dev/null`;
}
print html2Txt '<h1>Hi there!</h1> Testing <p>Testing</p>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.