#!/usr/bin/perl $ok = @ARGV == 2; if ($ok) { undef $LaTeX; $ARGV[0] =~ /-latex/ and $LaTeX = 1; $ARGV[0] =~ /-html/ and $LaTeX = 0; $ok = defined $LaTeX; } $input_file = $ARGV[1]; if ($ok) { $ok = (-r $input_file); } if (!$ok) { printf("usage $0: [-latex | -html] \n"); exit(1); } $prefix_category = $LaTeX ? '\categorie{' : '
'; $suffix_category = $LaTeX ? '}' : '
'; $begin_description = $LaTeX ? '\begin{description}' : '
'; $end_description = $LaTeX ? '\end{description}' : '
'; $begin_item = $LaTeX ? '\item[' : '
'; $begin_item_suffix = $LaTeX ? ']{' : ' '; $end_item = $LaTeX ? '}' : '
'; $begin_item2 = $LaTeX ? '' : '
'; $end_item2 = $LaTeX ? '' : '
'; require $input_file; if ($LaTeX) { begin_latex(); foreach (@personal) { println(" $_"); } println(' \endboite}}'); println('\setbox12\vtop{'); println(' {\boite #&#'); print (" $address"); foreach (@address) { println(" & $_"); } println(' \endboite}'); println(' \hbox{', $phone, $phone_number, '}'); println(' \hbox{', $email_title, $email, '}'); println('}'); println('\hbox to\hsize{\box11\hfill\box12}'); body(); println(''); println(''); println('\end{large}'); println('\end{document}'); } else { begin_html(); foreach (@personal) { println(" $_
"); } println(' '); println(' '); println(' '); println(' '); println(' '); println(' '); println(' '); println(' '); println('
', $address, ''); foreach (@address) { println(" $_
"); } println('
', $phone, $phone_number, '
'); println(' '); println(' '); println('

'); body(); println(''); println(''); } sub body { my $i; println(''); for ($i = 0; $i < @body; $i += 2) { println(''); println(''); println($prefix_category, $body[$i], $suffix_category); category($body[$i + 1], 0); } } sub category { my ($t, $depth) = @_; my ($j, $t2, $t3); println_depth($depth, $begin_description); for ($j = 0; $j < @$t; $j += 2) { print_depth($depth + 1, $begin_item, $$t[$j], $begin_item_suffix); ($depth > 0) and print_depth($depth + 1, $begin_item2); $t2 = $$t[$j + 1]; if (ref $t2) { foreach $t3 (@$t2) { if (ref $t3) { category($t3, $depth + 1); } else { println_depth($depth + 2, $t3); } } } else { print_depth($depth + 1, $t2); } ($depth > 0) and print_depth($depth + 1, $end_item2); println_depth($depth + 1, $end_item); } println_depth($depth, $end_description); } $last_print_depth = 0; sub println { print @_, "\n"; } sub print_depth { my $depth = shift; $last_print_depth or print(' ' x $depth); print @_; $last_print_depth = 1; } sub println_depth { my $depth = shift; $last_print_depth or print(' ' x $depth); println(@_); $last_print_depth = 0; } sub begin_latex { $size = ($size ? $size : 12); println('\documentclass[a4paper,', $size, 'pt]{article}'); println(''); println('\usepackage[french]{babel}'); println('\usepackage[T1]{fontenc}'); println('\usepackage{fullpage}'); println('\usepackage{times}'); println('\pagestyle{empty}'); println('\sloppy'); println(''); println('\setlength{\topmargin}{-3cm}'); println('\addtolength{\textheight}{4cm}'); println(''); println(''); println('\newbox\maBox\def\smashII#1{\setbox\maBox\hbox{#1} \dp\maBox=0pt \box\maBox}'); println(''); println('\def\boite{'); println(' \rightskip0ptplus1fil \spaceskip .3333em \xspaceskip .5em\relax'); println(' \let\par\cr \obeylines%'); println(' \long\def\endboite##1\endboite{\halign{##1}}\endboite}'); println(''); println('\def\categorie#1{\vskip.7cm\noindent\hspace{-5pt}%'); println(' {\large\textsl{\smashII{#1}}\par}\vskip2pt\hrule\vskip.2cm}'); println(''); println('\begin{document}'); println('\begin{large}'); println(''); println('\setbox11\vtop{'); println(' {\boite #'); } sub begin_html { $background_image = ($background_image ? " BACKGROUND=$background_image" : ''); println(''); println(''); println(' '); println(' CV'); println(' '); println(''); println(''); println(''); println(' '); println('
'); }