PPI::HTML(3pm)
π PPI::HTML π
okay bestie, so this is the manual page for PPI::HTML, living in the 3pm section of the manual, and it's literally the glow-up your Perl code deserves β¨
πΈ NAME πΈ
PPI::HTML β Generate syntax-hightlighted HTML for Perl using PPI π
β¨ SYNOPSIS β¨
use PPI;
use PPI::HTML;
# Load your Perl file
my $Document = PPI::Document->load( 'script.pl' );
# Create a reusable syntax highlighter
my $Highlight = PPI::HTML->new( line_numbers => 1 );
# Spit out the HTML
print $Highlight->html( $Document );
like, that's the whole vibe right there. four lines. icon. π
π¦ DESCRIPTION π¦
PPI::HTML converts Perl documents into syntax highlighted HTML pages. that's it, that's the job, and it does it flawlessly π
π HISTORY π
PPI::HTML is the successor to the now-redundant PPI::Format::HTML. out with the old, in with the slay.
so back in the day, the thought was that one single formatting code could handle a whole bunch of different output types all at once (ANSI and HTML, for example β like, multitasking queen energy). but then the here-doc code came along and things got messy, and the need for independently written serializers showed up, and ngl that whole plan had to be thrown out entirely π. it's giving "we tried".
plus β and this is the real tea β the old module only made use of the Tokenizer, and honestly its API was pretty shit, to boot π
π API Overview π
the new module is so much cleaner, no cap. you just make an object with the options you want, pass PPI::Document objects to the "html" method, and you get back strings of HTML that you can do literally whatever you want with. main character API energy fr fr.
π₯ METHODS π₯
β new %args
the "new" constructor takes a simple set of key/value pairs to define the formatting options for the HTML. easy.
pageβ if the"page"option is enabled, the generator will wrap the generated HTML fragment in a basic but complete page. like, full page mode, not just a lil fragment π«Άline_numbersβ at the present time, the only option available. if set to true, line numbers get added to the output. π’colors|coloursβ for the cases where you don't wanna use an external stylesheet, you can hand over"colors"as a hash reference, where the keys are CSS classes (generally matching the token name) and the values are colours. this lets you do basic colouring without needing a whole entire stylesheet. casual, effortless, iconic. πcssβ the"css"option lets you provide a customCSS::Tinyobject containing any CSS you want to apply to the page (if you're using page mode).
β οΈ heads up bestie: if both the"colors"and"css"options are used, the colour CSS entries will overwrite anything contained in theCSS::Tinyobject. also, the object will be cloned if it is to be modified, so you don't accidentally destroy any CSS objects you passed in. respect the clone π
Returns a new PPI::HTML object π
π§ css
the "css" accessor returns the CSS::Tiny object that was originally provided to the constructor. it remembers. it always remembers.
π html $Document | $file | \$source
the main method for the class, fr. the "html" method takes a single PPI::Document object, or anything that can be turned into a PPI::Document via its "new" method, and returns a string of HTML formatted based on the arguments given to the PPI::HTML constructor.
returns a string, or undef on error π
π SUPPORT π
bugs should always be submitted via the CPAN bug tracker:
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PPI-HTML>
for other issues, contact the maintainer π«Ά
π AUTHOR π
Adam Kennedy <adamk@cpan.org>
Funding provided by The Perl Foundation πΈ
π SEE ALSO π
<http://ali.as/>, PPI
π COPYRIGHT π
Copyright 2005 - 2009 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
and that's the whole page, bestie β this was PPI::HTML(3pm) from perl v5.36.0, dated 2022-11-20 π go highlight something pretty β¨ππ¦
π¦ where this page comes from
- debian bookworm: libppi-html-perl 1.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libppi-html-perl 1.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libppi-html-perl 1.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libppi-html-perl 1.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libppi-html-perl 1.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms