.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Highlight 3pm" .TH Highlight 3pm "2009-06-04" "perl v5.10.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" \&\fBHTML::Highlight \- A module to highlight words or patterns in \s-1HTML\s0 documents\fR .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use HTML::Highlight; \& \& # create the highlighter object \& \& my $hl = new HTML::Highlight ( \& words => [ \& \*(Aqword\*(Aq, \& \*(Aqany\*(Aq, \& \*(Aqcar\*(Aq, \& \*(Aqsome phrase\*(Aq \& ], \& wildcards => [ \& undef, \& \*(Aq%\*(Aq, \& \*(Aq*\*(Aq, \& undef \& ], \& colors => [ \& \*(Aq#FF0000\*(Aq, \& \*(Aqred\*(Aq, \& \*(Aqgreen\*(Aq, \& \*(Aqrgb(255, 0, 0)\*(Aq \& ], \& czech_language => 0, \& debug => 0 \& ); \& \& # Remember that you don\*(Aqt need to specify your own colors. \& # The default colors should be optimal. \& \& # Now you can use the object to highlight patterns in a document \& # by passing content of the document to its highlight() method. \& # The highlighter object "remembers" its configuration. \& \& my $highlighted_document = $hl\->highlight($document); .Ve .SH "MOTIVATION" .IX Header "MOTIVATION" This module was originaly created to work together with fulltext indexing module DBIx::TextIndex to highlight search results. .PP A need for a highlighter that takes wildcard matches and \s-1HTML\s0 tags into account and supports czech language (or other Slavic languages) was the motivation to create this module. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides Google-like highlighting of words or patterns in \s-1HTML\s0 documents. This feature is typically used to highlight search results. .IP "The construcutor:" 4 .IX Item "The construcutor:" .Vb 7 \& my $hl = new HTML::Highlight ( \& words => [], \& wildcards => [], \& colors => [], \& czech_language => 0, \& debug => 0 \& ); .Ve .Sp This is a constructor of the highlighter object. It takes an array of even number of parameters. .Sp The \fBwords\fR parameter is a reference to an array of words to highlight. .Sp The \fBwildcards\fR parameter is a reference to an array of wildcards, that are applied to corresponding words in the \fBwords\fR array. .Sp A wildcard can be either undef or one of '%' or '*'. .Sp \&\fBThe \*(L"%\*(R" character\fR means \*(L"match any characters\*(R": .Sp .Vb 1 \& "%" applied to \*(Aqcar\*(Aq ==> matches "car", "cars", "careful", ... .Ve .Sp \&\fBThe \*(L"*\*(R" character\fR means \*(L"match also plural form of the word\*(R": .Sp .Vb 1 \& "*" applied to \*(Aqcar\*(Aq ==> matches only "car" or "cars" .Ve .Sp \&\fBAn undefined wildcard\fR means \*(L"match exactly the corresponding word\*(R": .Sp .Vb 1 \& undefined wildcard applied to \*(Aqcar\*(Aq ==> matches only "car" .Ve .Sp The \fBcolors\fR parameter is a reference to an array of \s-1CSS\s0 color identificators, that are used to highlight the corresponding words in the \fBwords\fR array. .Sp Default Google-like colors are used if you don't specify your own colors. Number of colors can be lower than number of words \- in this case the colors are rotated and some of the words are therefore highlighted using the same color. .Sp The highlighter takes \s-1HTML\s0 tags into account and therefore does not \&\*(L"highlight\*(R" a word or a pattern inside a tag. .Sp A support for diacritics insenstive matching for \s-1ISO\-8859\-2\s0 languages (for for example the czech language) can be activated using the \fBczech_language\fR option. This feature requires a module \fBCzFast\fR that is available on \s-1CPAN\s0 in a directory of author \s-1TRIPIE\s0 or at http://geocities.com/tripiecz/. .Sp \&\fBYour system's locales must be set correctly to use the czech_language feature.\fR .IP "highlight" 4 .IX Item "highlight" .Vb 1 \& my $hl_document = $hl\->highlight($document); .Ve .Sp The only parameter is a document in that you want to highlight the words that were passed to the constructor of the highlighter object. The method returns a version of the document in which the words are highlighted. .IP "preview_context" 4 .IX Item "preview_context" .Vb 1 \& my $sections = $hl\->preview_context($document, $num); .Ve .Sp This method takes two parameters. The first one is the document you want to scan for the words that were passed to the constructor of the highlighter object. The second parameter is an optional integer that specifies maximum number of characters in each of the context sections (see below). This parameter defaults to 80 characters if it's not specified. Minimum allowed value of this parameter is 60. .Sp The method returns a reference to an array of sections of the document in which the words that were passed to the constructor appear. \&\s-1HTML\s0 tags are removed before the document is proccessed and are not present in the ouput. This feature is typically used in search engines to preview a context in which words from a search query appear in the resulting documents. The words are always in the middle of each of the sections. The number of sections this method returns is equal to the number of words passed to the constructor of the highlighter object. That means only the first occurence of each of the words is taken into account. .SH "SUPPORT" .IX Header "SUPPORT" No official support is provided, but I welcome any comments, patches and suggestions on my email. .SH "BUGS" .IX Header "BUGS" I am aware of no bugs. .SH "AVAILABILITY" .IX Header "AVAILABILITY" .Vb 1 \& http://geocities.com/tripiecz/ .Ve .SH "AUTHOR" .IX Header "AUTHOR" \&\fBTomas Styblo\fR, tripie@cpan.org, CPAN-ID \s-1TRIPIE\s0 .PP Prague, the Czech republic .SH "LICENSE" .IX Header "LICENSE" HTML::Highlight \- A module to highlight words or patterns in \s-1HTML\s0 documents .PP Copyright (C) 2000 Tomas Styblo (tripie@cpan.org) .PP This module is free software; you can redistribute it and/or modify it under the terms of either: .PP a) the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or .PP b) the \*(L"Artistic License\*(R" which comes with this module. .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See either the \s-1GNU\s0 General Public License or the Artistic License for more details. .PP You should have received a copy of the Artistic License with this module, in the file Artistic. If not, I'll be glad to provide one. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, \s-1MA\s0 02111\-1307 \&\s-1USA\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIperl\fR\|(1).