# $Id$ use Text::Wrap; my $COLUMNS = 76; $Text::Wrap::columns = $COLUMNS; sub nothing(@) { $_[2] } %DISPATCH = ( b => \¬hing, i => \¬hing, u => \¬hing, strong => \¬hing, em => \¬hing, br => sub { "\n" }, a => \¬hing, resume => \¬hing, author => \¢er, address => \&address, education => \&education, school => \&school, experience => \&experience, employer => \&employer, skills => \&skills, skill => \&skill, references => \¢er, ); # Warning, does not gracefully handle overfull row! sub _center($) { my $text = shift; chomp $text; return ' ' x int(($COLUMNS - length $text) / 2) . $text . "\n"; } sub center($) { my $text = $_[2]; if($text =~ m/\n/) { my $returnvalue = ''; $returnvalue .= _center $_ foreach split "\n", $text; return $returnvalue; } else { return _center $text; } } # Warning, does not gracefully handle overfull row sub leftright($$) { my($left, $right) = @_; chomp $left; chomp $right; my $between = $COLUMNS - (length($left) + length($right)); return join '', $left, ' ' x $between, $right, "\n"; } sub address { ¢er . "\n" } sub education { "Education\n\n" . $_[2] } sub experience { "Work Experience\n\n" . $_[2] } sub skills { "Applicable Job Skills\n\n" . $_[2] . "\n" } sub school { my($tag, $attribute, $text) = @_; my($name, $location) = map {$attribute->{$_}} qw(name location); wrap('', '', $name . ($location ? " ($location)" : '')) . "\n" . wrap(' ', ' ', $text) . "\n\n"; } sub employer { my($tag, $attribute, $text) = @_; my($name, $location, $dates, $position) = map {$attribute->{$_}} qw(name location dates position); wrap('', '', $name) . "\n" . leftright($location, $dates) . wrap(" $position\. ", ' ', $text) . "\n\n"; } sub skill { my($tag, $attribute, $text) = @_; wrap(' * ', ' ', $text) . "\n"; } 1;