latex.pm - a perl module to extract elements from a LaTeX file
@a = greplatexenv("letter",["to"],"myletter,tex") ;
print $a[0]->{to}
print $a[0]->{env}
@l_section = greplatexcom("section",["title"],"myart.tex");
for $s (@l_section) {print $s->{title} };
@class = greplatexcom("documentclass",[["args"],"class"],"myart.tex");
print $class[0]->{class} ;
$abstract = theenv("abstract","myart.tex");
print tex2html($abstract);
greplatexenv - to get all ocurrences of an environment
@a = greplatexenv("letter",["to"],"myletter,tex") ;
greplatexenv returns a list of all the ocurrences of environment ``letter'', reading its
firts argument to the ``to'' field and saving its content in the ``env''
field;
theenv - to get an environment contents
$abstract = theenv("abstract","myart.tex");
theenv returns the contents of the environment ``abstract''.
greplatexcom - to get all ocurrences of a command
@l_section = greplatexcom("section",["title"],"myart.tex");
for $s (@l_section) {print $s->{title} };
Opcional arguments can be described with ``[name]''. See example
@class = greplatexcom("documentclass",[["args"],"class"],"myart.tex");
print $class[0]->{class} ;
bichop - Double end chop
bichop("{aaa}")
is
"aaa"
tex2html - tex to html translation function
tex2html("\section{Section one}")
is
"<h2> Section one </h2>"
You need tth comand intalled in your path...!
#!/usr/local/bin/perl
use latex;
$f=shift;
@doc = greplatexcom("documentclass",[["args"],"t"],$f);
@t= greplatexcom("title",["t"],$f);
@sec= greplatexcom("section",["t"],$f);
@au= greplatexcom("author",["t"],$f);
@date= greplatexcom("date",["t"],$f);
$abs= theenv("abstract",$f);
$type = bichop($doc[0]->{"t"});
$aut = $au[0]->{t};
($k= $aut) =~ tr{a-záéíóúãõâêôç {}}{}d ;
print
"\@$type\{$k,
author=$aut,
title=$t[0]->{t},
abstract={$abs},
year=$date[0]->{t}}\n\n";
jj@di.uminho.py