#! /usr/bin/perl # $Id: dict2html,v 1.1 2000/06/27 15:27:12 villate Exp $ # # dict2html - program to create an html version of the orca glossary. # Copyright (C) Jaime Villate , 2000 # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Jaime Villate, Faculdade de Engenharia, Rua dos Bragas, 4050-123 Porto # Portugal # # The ORCA project =head1 NAME dict2html - Creates an HTML version of glosario.dict =head1 SYNOPSIS S =head1 DESCRIPTION This programs reads the glosario.dict text file and creates a HTML version of it. =head1 AUTHOR Jaime Villate Evillate@fe.up.ptE. =cut use strict vars; use vars qw($info $short $url $author $version $first $letter); my $usage = "Usage: $0 \n"; my $keyw = ''; my $text = ''; my $word = ''; my $item = 0; die $usage if ($#ARGV != 0); my $filehandle = $ARGV[0]; die usage if ($filehandle =~ /^\-/); die "$0: cannot find $filehandle.\n" if ! -f $filehandle; (my $htmlname = $filehandle) =~ s/\.dict/\.html/; open(DICT, "< $filehandle"); open(HTML,"> $htmlname"); while () { if (/^([^0\#\s])/) { chop; $word = $_; $first = uc($1); if ($item == 0) { preamble(); $item = 1; $letter = $first; print HTML qq{$letter }; print HTML qq{(ir al índice)}; print HTML qq{
\n
\n}; } else { print HTML qq{
$keyw
$text.
\n}; if ($first ne $letter) { $letter = $first; print HTML qq{
\n

\n}; print HTML qq{$letter (ir al índice)
\n
\n}; } } $keyw = $word; $text = ''; } else { $text .= $_ if (/\S/); } if ($item == 0) { $author = $1, next if (/^\s*Autor:(.*)$/); $version = $1, next if (/^\s*(Versión.*)$/); } } close DICT; print HTML qq{
$keyw
$text.
\n} if ($keyw =~ /^[^0\#]/); print HTML qq{
\n\n

}; print HTML qq{Bibliografía

(ir al }; print HTML qq{índice)
\n
    \
  1. \n

    \n\n}; open (BIB, ') { if (/\S/) { $text = fmturl($_); if ($item == 0) { $item = 1; print HTML "

    \n
  2. \n
  3. \n

    \n"; } print HTML " $text"; } else { $item = 0; } } close BIB; print HTML qq{

    \n
  4. \n
\n\n

}; print HTML qq{Colaboradores

(ir al }; print HTML qq{índice)
\n
    \n}; open (COL, ') { if (/\S/) { $text = fmturl($_); print HTML "
  • \n

    $text

    \n
  • \n"; } } close COL; print HTML "
\n\n\n"; close HTML; exit; sub preamble { $author = fmturl($author); print HTML <<"EndPreamble"; Glosario de informática Inglés-Español

Glosario de informática Inglés-Español

($version)

ORCA

Copyright © Jaime Villate, 2000. Este documento es libre. Puede copiarlo, distribuirlo y/o modificarlo bajo los términos de la Licencia GNU Para Documentación Libre, versión 1.1 o cualquier versión posterior publicada por la Free Software Foundation.

Prefacio

EndPreamble open (PRE, ') { if (/\S/) { $text = fmturl($_); print HTML $text; } else { print HTML "

\n

\n"; } } print HTML "

\n"; close PRE; print HTML <<"Navigation";

Glosario

Navigation foreach my $i ('A'..'M','Bibliografía') { print HTML qq{ \n}; } print HTML qq{ \n}; foreach my $i ('N'..'Z','Colaboradores') { print HTML qq{ \n}; } print HTML qq{
$i
$i
\n

\n}; } sub fmturl { (my $line) = @_; $line =~ s/[\<\(]?([\w\.]+\@[\w\.]+)[\>\)]?/$1<\/a>/g; $line =~ s/[\<\(]?(h?[tf]tp:\/\/[\w\/\.\~\%]+)[\>\)]?/$1<\/a>/g; return $line; }