|
NAMESyntax::Highlight::Shell - Highlight shell scriptsVERSIONVersion 0.04SYNOPSISuse Syntax::Highlight::Shell; my $highlighter = new Syntax::Highlight::Shell; $output = $highlighter->parse($script); If $script contains the following shell code: # an if statement if [ -f /etc/passwd ]; then grep $USER /etc/passwd | awk -F: '{print $5}' /etc/passwd fi then the resulting HTML contained in $output will render like this: DESCRIPTIONThis module is designed to take shell scripts and highlight them in HTML with meaningful colours using CSS. The resulting HTML output is ready for inclusion in a web page. Note that no reformating is done, all spaces are preserved.METHODS
Example To avoid surrounding the result by the "<pre>...</pre>" tags: my $highlighter = Syntax::Highlight::Shell->new(pre => 0);
Internal MethodsThe following methods are for internal use only.
NOTESThe resulting HTML uses CSS to colourize the syntax. Here are the classes that you can define in your stylesheet.
An example stylesheet can be found in examples/shell-syntax.css. EXAMPLEHere is an example of generated HTML output. It was generated with the script eg/highlight.pl.The following shell script #!/bin/sh user="$1" case "$user" in # check if the user is root 'root') echo "You are the BOFH." ;; # for normal users, grep throught /etc/passwd *) passwd=/etc/passwd if [ -f $passwd ]; then grep "$user" $passwd | awk -F: '{print $5}' else echo "No $passwd" fi esac will be rendered like this (using the CSS stylesheet eg/shell-syntax.css): CAVEATS"Syntax::Highlight::Shell" relies on "Shell::Parser" for parsing the shell code and therefore suffers from the same limitations.SEE ALSOShell::ParserAUTHORSébastien Aperghis-Tramoni, <sebastien@aperghis.net>BUGSPlease report any bugs or feature requests to "bug-syntax-highlight-shell@rt.cpan.org", or through the web interface at <https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Syntax-Highlight-Shell>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.COPYRIGHT & LICENSECopyright 2004 Sébastien Aperghis-Tramoni, All Rights Reserved.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |