text-vimcolor - Use Text:VimColor from the command line
$ text-vimcolor FILENAME # (like a colored "cat" (same as "text-vimcolor --format ansi FILENAME")) $ text-vimcolor --format html --full-page FILENAME > OUTPUT.html $ text-vimcolor --format xml FILENAME > OUTPUT.xml $ text-vimcolor --format pdf FILENAME --output OUTPUT.pdf
This program uses the Vim text editor to highlight text according to its syntax, and turn the highlighting into ANSI, HTML, XML or PDF output. It works with any file type which Vim itself can highlight. Usually Vim will be able to auto-detect the file format based on the filename (and sometimes the contents of the file).
Exactly one filename should be given on the command line to name the input file. If none is given input will instead be read from
If Vim can't guess the file type automatically, it can be specified explicitly using the
--filetype option. For example:
$ text-vimcolor --format html --filetype prolog foo.pl > foo.html
This program is a command line interface to the Perl module Text::VimColor.
The following options are understood:
Show a summary of the usage, including a list of options.
Turns on debugging in the underlying Perl module. This makes it print the command used to run Vim.
Enables additional syntax groups instead of just the primary ones. See "all_syntax_groups" in Text::VimColor for more information.
- --filetype file-type
Set the type of the file explicitly. The file-type argument should be something which Vim will recognize when set with its
filetypeoption. Examples are
cpp(for C++) and
sh(for Unix shell scripts). These names are case sensitive, and should usually be all-lowercase.
- --format output-format
The output format to generate. Must be one of the following:
Output text marked up with ANSI escape sequences (using Term::ANSIColor). This is like a colorized version of
You can alter the color scheme using the
TEXT_VIMCOLOR_ANSIenvironment variable in the format of
"SynGroup=color;". For example:
TEXT_VIMCOLOR_ANSI='Comment=green;Statement = magenta; '
On windows the script will attempt to load Win32::Console::ANSI if the output is to STDOUT in an attempt to make the output more useful. You can disable this by setting
Generate XHTML output, with text marked with
classattributes. A CSS stylesheet should be used to define the coloring, etc., for the output. See the
Output is in a simple XML vocabulary. This can then be used by other software to do further transformations (e.g., using XSLT).
XML output is generated and fed to the FOP XSL-FO processor, with an appropriate XSL style sheet. The stylesheet uses XSLT to transform the normal XML output into XSL-FO, which is then rendered to PDF. For this to work, the command
fopmust be available. An output file must be specified with
--outputwith this format.
Full details of the HTML and XML output formats can be found in the documentation for Text::VimColor.
- --output output-filename
Specifies the name of the output file. If this option is omitted, the output will be sent to <STDOUT>. This option is required when the output format is PDF (because of limitations in FOP).
When the output format is HTML, this option will make the output a complete HTML page, rather than just a fragment of HTML. A CSS stylesheet will be inserted inline into the output, so the output will be usable as it is.
When the output format is HTML and
--fullpageis given, a stylesheet is normally inserted in-line in the output file. If this option is given it will instead be referenced with a
- --let name=value
When Vim is run the value of name will be set to value using Vim's
letcommand. More than one of these options can be set. The value is not quoted or escaped in any way, so it can be an expression. These settings take precedence over
This option corresponds to the
vim_letsetting and method in the Perl module.
- --unlet name
Prevent the value of name being set with Vim's
letcommand. This can be used to turn off default settings.
This option corresponds to the
vim_letsetting and method in the Perl module, when used with a value of
The PDF output option often doesn't work, because it is dependent on FOP, which often doesn't work. This is also why it is mind numbingly slow.
FOP (0.20.3) seems to ignore the
<fo:inline>. If that's what it's meant to do, how do you set the background color on part of a line?
Geoff Richards <firstname.lastname@example.org>
Randy Stauner <email@example.com>
This software is copyright (c) 2002-2006 by Geoff Richards.
This software is copyright (c) 2011 by Randy Stauner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.