GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  SYNTAX::HIGHLIGHT::HTML (3)

.ds Aq ’

NAME

Syntax::Highlight::HTML - Highlight HTML syntax

CONTENTS

VERSION

Version 0.04

SYNOPSIS



    use Syntax::Highlight::HTML;

    my $highlighter = new Syntax::Highlight::HTML;
    $output = $highlighter->parse($html);



If $html contains the following HTML fragment:



    <!-- a description list -->
    <dl compact="compact">
      <dt>some word</dt>
      <dd>the description of the word. Plus some <a href="/definitions/other_word"
      >reference</a> towards another definition. </dd>
    </dl>



then the resulting HTML contained in $output will render like this:

DESCRIPTION

This module is designed to take raw HTML input and highlight it (using a CSS stylesheet, see Notes for the classes). The returned HTML code is ready for inclusion in a web page.

It is intented to be used as an highlighting filter, and as such does not reformat or reindent the original HTML code.

METHODS

new() The constructor. Returns a Syntax::Highlight::HTML object, which derives from HTML::Parser. As such, any HTML::parser method can be called on this object (that is, expect for parse() which is overloaded here).

<B>OptionsB>
o nnn - Activate line numbering. Default value: 0 (disabled).
o pre - Surround result by <pre>...</pre> tags. Default value: 1 (enabled).

<B>ExampleB>

To avoid surrounding the result by the <pre>...</pre> tags:



    my $highlighter = Syntax::Highlight::HTML->new(pre => 0);



parse() Parse the HTML code given in argument and returns the highlighted HTML code, ready for inclusion in a web page.

<B>ExampleB>



    $highlighter->parse("<p>Hello, world.</p>");



    Internals Methods

The following methods are for internal use only.
_highlight_tag() HTML::Parser tags handler: highlights a tag.
_highlight_text() HTML::Parser text handler: highlights text.

NOTES

The resulting HTML uses CSS to colourize the syntax. Here are the classes that you can define in your stylesheet.
o .h-decl - for a markup declaration; in a HTML document, the only markup declaration is the DOCTYPE, like: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
o .h-pi - for a process instruction like <?html ...> or <?xml ...?>
o .h-com - for a comment, <!-- ... -->
o .h-ab - for the characters < and > as tag delimiters
o .h-tag - for the tag name of an element
o .h-attr - for the attribute name
o .h-attv - for the attribute value
o .h-ent - for any entities: é «
o .h-lno - for the line numbers
An example stylesheet can be found in eg/html-syntax.css.

EXAMPLE

Here is an example of generated HTML output. It was generated with the script eg/highlight.pl.

The following HTML fragment (which is the beginning of <http://search.cpan.org/~saper/>)



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
     <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <link rel="stylesheet" href="/s/style.css" type="text/css">
      <title>search.cpan.org: Sébastien Aperghis-Tramoni</title>
     </head>
     <body id="cpansearch">
    <center><div class="logo"><a href="/"><img src="/s/img/cpan_banner.png" alt="CPAN"></a></div></center>
    <div class="menubar">
     <a href="/">Home</a>
    · <a href="/author/">Authors</a>
    · <a href="/recent">Recent</a>
    · <a href="/news">News</a>
    · <a href="/mirror">Mirrors</a>
    · <a href="/faq.html">FAQ</a>
    · <a href="/feedback">Feedback</a>
    </div>
    <form method="get" action="/search" name="f" class="searchbox">
    <input type="text" name="query" value="" size="35">
    <br>in <select name="mode">
     <option value="all">All</option>
     <option value="module" >Modules</option>
     <option value="dist" >Distributions</option>
     <option value="author" >Authors</option>
    </select> <input type="submit" value="CPAN Search">
    </form>



will be rendered like this (using the CSS stylesheet eg/html-syntax.css):

CAVEATS

Syntax::Highlight::HTML relies on HTML::Parser for parsing the HTML and therefore suffers from the same limitations.

SEE ALSO

HTML::Parser

AUTHORS

Se\k:'Aperghis-Tramoni, <sebastien@aperghis.net>

BUGS

Please report any bugs or feature requests to bug-syntax-highlight-html@rt.cpan.org, or through the web interface at <https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Syntax-Highlight-HTML>. I will be notified, and then you’ll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright (C)2004 Se\k:'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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 SYNTAX::HIGHLIGHT::HTML (3) 2005-04-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.