Text_Highlighter
[ class tree: Text_Highlighter ] [ index: Text_Highlighter ] [ all elements ]
Prev Next

Command-line class generation tool

Example from previous section looks pretty simple, but it does not handle any errors which may occur during parsing of XML source. The package provides a command-line script to make generation of classes even more simple, and takes care of possible errors. It installs in scripts/Text/Highlighter directory and is called generate (on Unix/Linux) or generate.bat (on Windows). This script is able to process multiple files in one run, and also to process XML from standard input and write generated code to standard output.

Usage:
generate options

Options:
  -x filename, --xml=filename
        source XML file. Multiple input files can be specified, in which
        case each -x option must be followed by -p unless -d is specified
        Defaults to stdin
  -p filename, --php=filename
        destination PHP file. Defaults to stdout. If specied multiple times,
        each -p must follow -x
  -d dirname, --dir=dirname
        Default destination directory. File names will be taken from XML input
        ("lang" attribute of <highlight> tag)
  -h, --help
        This help

Examples

Read from php.xml, write to PHP.php
generate -x php.xml -p PHP.php

Read from php.xml, write to standard output
generate -x php.xml

Read from php.xml, write to PHP.php, read from xml.xml, write to XML.php
generate -x php.xml -p PHP.php -x xml.xml -p XML.php

Read from php.xml, write to /some/dir/PHP.php, read from xml.xml, write to /some/dir/XML.php (assuming that xml.xml contains <highlight lang="xml">, and php.xml contains <highlight lang="php">)
generate -x php.xml -x xml.xml -d /some/dir/


Prev Up Next
Creating a syntax highlighter

Documentation generated on Mon, 11 Mar 2019 13:51:46 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.