TeX::DVI::Parse - parse TeX's DVI output file
use TeX::DVI::Parse; my $dvi_parse = new TeX::DVI::Parse("test.dvi"); $dvi_parse->parse();
I have created this module on request from Mirka Misáková. She wanted to do some post-processing on the DVI file and I said that it will be better to parse the DVI file directly, instead of the output of the dvitype program.
As the result there is this module TeX::DVI::Parse that recognizes all commands from the DVI file and for each command found it calls method of appropriate name, if defined in the class.
The example above is not very reasonable because the core TeX::DVI::Parse module doesn't itself define any methods for the DVI commands. You will probably want to inherit a new class and define the functions yourself:
packages My_Parse_DVI; use TeX::DVI::Parse; @ISA = qw( TeX::DVI::Parse ); sub set_char { my ($self, $ord, $char) = @_; ## print the info or something; }
As an example there is class TeX::DVI::Print coming in this file, so you can do
use TeX::DVI::Parse; my $dvi_parse = new TeX::DVI::Print("test.dvi"); $dvi_parse->parse();
and get listing of DVI's content printed in (hopefully) readable form.
For creating new classes, a documentation of expected methods names and their parameters is necessary, so here is the list. The names come from the dvitype documentation and that is also the basic reference for the meaning of the parameters. Note that each method receives as the first two parameters $self and $ord, reference to the parsing object and the byte value of the command as found in the DVI file. These are mandatory so only the other parameters to each method are listed below.
$char -- specifies the ordinal value of the character.
$char -- ordinal value of the character.
$height, $width -- dimensions of the rectangle.
no parameter
$number[0] .. $number[9], $prev_page -- the ten numbers that specify the page, the pointer to the start of the previous page.
$value -- how much to move.
all take one parameter, $value.
$k, $c, $s, $d, $a, $l, $n -- number of the font, checksum, scale factor, design size, length of the directory and length of the filename, name of the font.
$k -- number of the font.
$k, $x -- length of the special and its data.
$i, $num, $den, $mag, $k, $x -- ID of the format, numerator and denumerator of the multiplication fraction, magnification, length of the comment and comment.
$p, $num, $den, $mag, $l, $u, $s, $t -- pointer to the last page, the next three are as in preamble, maximal dimensions ($l and $u), maximal depth of the stack and the final page number.
$q, $i, $dummy -- pointer to the postamble, ID and the last fill.
1.01
http://www.adelton.com/perl/TeX-DVI/
(c) 1996--2011 Jan Pazdziora.
All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Contact the author at jpx dash perl at adelton dot com.
Font::TFM(3), TeX::DVI(3), perl(1).
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Misáková.'. Assuming CP1252
To install TeX::DVI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TeX::DVI
CPAN shell
perl -MCPAN -e shell install TeX::DVI
For more information on module installation, please visit the detailed CPAN module installation guide.