.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13) .\" .\" 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 "Text::VimColor 3pm" .TH Text::VimColor 3pm "2006-02-19" "perl v5.10.1" "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" Text::VimColor \- syntax color text in HTML or XML using Vim .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& use Text::VimColor; \& my $syntax = Text::VimColor\->new( \& file => $0, \& filetype => \*(Aqperl\*(Aq, \& ); \& \& print $syntax\->html; \& print $syntax\->xml; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module tries to markup text files according to their syntax. It can be used to produce web pages with pretty-printed colourful source code samples. It can produce output in the following formats: .IP "\s-1HTML\s0" 4 .IX Item "HTML" Valid \s-1XHTML\s0 1.0, with the exact colouring and style left to a \s-1CSS\s0 stylesheet .IP "\s-1XML\s0" 4 .IX Item "XML" Pieces of text are marked with \s-1XML\s0 elements in a simple vocabulary, which can be converted to other formats, for example, using \s-1XSLT\s0 .IP "Perl array" 4 .IX Item "Perl array" A simple Perl data structure, so that Perl code can be used to turn it into whatever is needed .PP This module works by running the Vim text editor and getting it to apply its excellent syntax highlighting (aka 'font\-locking') to an input file, and mark pieces of text according to whether it thinks they are comments, keywords, strings, etc. The Perl code then reads back this markup and converts it to the desired output format. .PP This is an object-oriented module. To use it, create an object with the \f(CW\*(C`new\*(C'\fR function (as shown above in the \s-1SYNOPSIS\s0) and then call methods to get the markup out. .SH "METHODS" .IX Header "METHODS" .IP "new(\fIoptions\fR)" 4 .IX Item "new(options)" Returns a syntax highlighting object. Pass it a hash of options. .Sp The following options are recognised: .RS 4 .IP "file" 4 .IX Item "file" The file to syntax highlight. Can be either a filename or an open file handle. .Sp Note that using a filename might allow Vim to guess the file type from its name if none is specified explicitly. .Sp If the file isn't specified while creating the object, it can be given later in a call to the \f(CW\*(C`syntax_mark_file\*(C'\fR method (see below), allowing a single Text::VimColor object to be used with multiple input files. .IP "string" 4 .IX Item "string" Use this to pass a string to be used as the input. This is an alternative to the \f(CW\*(C`file\*(C'\fR option. A reference to a string will also work. .Sp The \f(CW\*(C`syntax_mark_string\*(C'\fR method (see below) is another way to use a string as input. .IP "filetype" 4 .IX Item "filetype" Specify the type of file Vim should expect, in case Vim's automatic detection by filename or contents doesn't get it right. This is particularly important when providing the file as a string of file handle, since Vim won't be able to use the file extension to guess the file type. .Sp The filetypes recognised by Vim are short strings like 'perl' or 'lisp'. They are the names of files in the 'syntax' directory in the Vim distribution. .Sp This option, whether or not it is passed to \f(CW\*(C`new()\*(C'\fR, can be overridden when calling \f(CW\*(C`syntax_mark_file\*(C'\fR and \f(CW\*(C`syntax_mark_string\*(C'\fR, so you can use the same object to process multiple files of different types. .IP "html_full_page" 4 .IX Item "html_full_page" By default the \f(CW\*(C`html()\*(C'\fR output method returns a fragment of \s-1HTML\s0, not a full file. To make useful output this must be wrapped in a \f(CW\*(C`
\*(C'\fR
element and a stylesheet must be included from somewhere.  Setting the
\&\f(CW\*(C`html_full_page\*(C'\fR option will instead make the \f(CW\*(C`html()\*(C'\fR method return a
complete stand-alone \s-1XHTML\s0 file.
.Sp
Note that while this is useful for testing, most of the time you'll want to
put the syntax highlighted source code in a page with some other content,
in which case the default output of the \f(CW\*(C`html()\*(C'\fR method is more appropriate.
.IP "html_inline_stylesheet" 4
.IX Item "html_inline_stylesheet"
Turned on by default, but has no effect unless \f(CW\*(C`html_full_page\*(C'\fR is also
enabled.
.Sp
This causes the \s-1CSS\s0 stylesheet defining the colours to be used
to render the markup to be be included in the \s-1HTML\s0 output, in a
\&\f(CW\*(C`