HTML::...::Lynx(3pm)

πŸ“¦
version 26 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– HTML::FormatText::Lynx β€” the whole vibe πŸ’–

okay bestie, so this is HTML::FormatText::Lynx(3pm) and it's literally a Perl module that takes HTML and turns it into plain text, using the actual lynx program to do the heavy lifting. no cap. let's get into it πŸ¦‹


✨ NAME ✨

HTML::FormatText::Lynx β€” format HTML as plain text using lynx. that's it, that's the whole job description, and it slays πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

here's how you use it, fr fr:

use HTML::FormatText::Lynx;
$text = HTML::FormatText::Lynx->format_file ($filename);
$text = HTML::FormatText::Lynx->format_string ($html_string);

$formatter = HTML::FormatText::Lynx->new (rightmargin => 60);
$tree = HTML::TreeBuilder->new_from_file ($filename);
$text = $formatter->format ($tree);

see? you got your format_file, your format_string, and if you're feeling fancy you can make a new formatter with a rightmargin and feed it a whole HTML::TreeBuilder tree. main character energy honestly πŸ‘‘


🌸 DESCRIPTION 🌸

so HTML::FormatText::Lynx turns HTML into plain text using the lynx program. iconic behavior. the home of that program is right here:

<http://lynx.isc.org/>

the module interface is compatible with formatters like HTML::FormatText, bestie β€” same vibe, same shape β€” but all the parsing and everything else is done by lynx, not by Perl. that's the plot twist πŸ¦‹

now go look at HTML::FormatExternal for the formatting functions and options. all of them are supported by HTML::FormatText::Lynx, no notes. but there are a couple of caveats, and the caveats are important, so don't skip this part πŸ™ˆ

leftmargin, rightmargin

before the -nomargins option showed up in Lynx 2.8.6dev.12 (June 2005), an extra 3 space margin is always applied within whatever left and right positions you asked for. so like, old lynx gonna old lynx, and you just have to live with those 3 extra spaces 😭

input_charset, output_charset

heads up: latin-1 and friends are not accepted here. it's gotta be iso-8859-1 and friends. no shortcuts, bestie, the strict name is the whole point.

also, output_charset becomes the -display_charset option, which means it can't be used on very old lynx that doesn't even have that option (like, say, lynx circa 2.8.1). rip. and maybe someday output_charset could be dropped if it's already whatever will be output anyway, or a Perl error could get thrown when it's unsupported β€” but that's future talk, not current facts, iykyk.


🎁 Extra Options 🎁

these are the bonus little treats this module gives you on top of the standard set πŸ’–

  • justify (boolean) β€” if it's true then -justify gets passed to lynx, which pads out all the lines in the paragraph with extra spaces up to the given rightmargin (or the default right margin if you didn't set one). very neat, very aligned ✨
  • unique_links (boolean) β€” if it's true then -unique_urls gets passed, so lynx gives its link footnotes just once for each distinct URL and then re-uses them whenever the same URL shows up again in the document. and just so you know: this module option is per HTML::FormatText::WithLinks. noted πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

go read them, they're good for you, it's giving well-informed 🌈


🏠 HOME PAGE 🏠

<http://user42.tuxfamily.org/html-formatexternal/index.html>

that's the house this module lives in, come visit ⭐


πŸ‘‘ LICENSE πŸ‘‘

Copyright 2008, 2009, 2010, 2013, 2015 Kevin Ryde

HTML-FormatExternal is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

HTML-FormatExternal is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with HTML-FormatExternal. If not, see <http://www.gnu.org/licenses/>.


so yeah, that's the whole thing. free software, GPL v3 or later, no warranty, all the legal bits intact because we respect the paperwork around here 🫢

and that's a wrap, bestie β€” this page was served up by perl v5.36.0 on 2022-11-19, and it's the HTML::...::Lynx(3pm) manpage, now with 100% more sparkle and exactly the same amount of facts. periodt πŸ’œ

πŸ“¦ where this page comes from