NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
HTML in vim (Score:2)
--
xoa
Re:HTML in vim (Score:1)
Re:HTML in vim (Score:2)
--
xoa
Re:HTML in vim (Score:1)
Hmmh, looks as though lynx can't read HTML stream-wise. Same limitation applies to links. w3m however can do it but doesn't appear to understand this sort of HTML-bastardism. The result is basically identical to what got piped in.
":%!html2text -nobs"works but then there are no linebreaks for Plain Old Text format.Currently, I use
IPC::Open2to do it inside my module:sub get_entry {
my $id = shift or return;
my $ret = $S->get_entry($id);
return if _had_error($ret) or (my $entry = $ret->result);
my $pid = open2 (\*OUT, \*IN, "html2text", "-style", "pretty", "-nobs");
$entry->{body} =~ s"<(/?)ecode>"<$1code>"g;
$entry->{body} =~ s"\n"<br>"g;
$entry->{body} =~
s"<code>(.*?)</code>"
'<code>' . do { (my $s = $1) =~ s/\s/ /g;$s } . '</code>'"gsex;
return $entry->{body} if $@ =~
print IN $entry->{body};
close IN;
my @output = <OUT>;
waitpid $pid, 0;
return join "\015", @output;
}
I'd really like to use something like
HTML::FormatText. But it expects anHTML::TreeBuilderobject to render. I have my doubts that it is that easy to turn the journal entry sources into such a tree since they aren't complete HTML documents.Anyway, the whole business keeps me busy and is intriguing so I am not even complaining that much.
Reply to This
Parent