HTML::FormatText - Format HTML as plaintext
| Use Case | Command | Description |
|---|---|---|
| đ§ Format an HTML file to plaintext | HTML::FormatText->format_file('file.html') | Parse and format an HTML file to plaintext with default margins. |
| đ Format with custom margins | HTML::FormatText->new(leftmargin => 0, rightmargin => 50)->format($tree) | Create a formatter with specified left and right margins. |
| đŗ Combine with HTML::TreeBuilder | $tree = HTML::TreeBuilder->new->parse_file("test.html"); $formatter->format($tree) | Parse HTML into a tree, then format it. |
version 2.12
use HTML::TreeBuilder;
$tree = HTML::TreeBuilder->new->parse_file("test.html");
use HTML::FormatText;
$formatter = HTML::FormatText->new(leftmargin => 0, rightmargin => 50);
print $formatter->format($tree);
or, more simply:
use HTML::FormatText;
my $string = HTML::FormatText->format_file(
'test.html',
leftmargin => 0, rightmargin => 50
);
HTML::FormatText is a formatter that outputs plain latin1 text. All character attributes (bold/italic/underline) are ignored. Formatting of HTML tables and forms is not implemented.
HTML::FormatText is built on HTML::Formatter and documentation for that module applies to this - especially "new" in HTML::Formatter, "format_file" in HTML::Formatter and "format_string" in HTML::Formatter.
You might specify the following parameters when constructing the formatter:
See perlmodinstall for information and options on installing Perl modules.
You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=HTML-Format.
The project homepage is https://metacpan.org/release/HTML-Format.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/HTML::Format/.
This software is copyright (c) 2015 by Nigel Metheringham, 2002-2005 Sean M Burke, 1999-2002 Gisle Aas.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-19 11:07 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format