# $Id$ use Text::Wrap qw(wrap); use vars qw(%DISPATCH $ME $TODAY); %DISPATCH = ( b => sub { "$_[2] " }, i => sub { "$_[2] " }, u => sub { "$_[2] " }, strong => sub { "$_[2] " }, em => sub { "$_[2] " }, br => sub { "
\n" }, a => \&a, resume => \&resume, author => \&author, address => \&address, education => \&education, school => \&school, experience => \&experience, employer => \&employer, skills => \&skills, skill => \&skill, references => \&references, ); sub education { header('Education') . $_[2] } sub experience { header('Work Experience') . $_[2] } sub skills { header('Applicable Job Skills') . " \n\n" } sub header($) { my $header = shift || return ''; my $canonical = $header; $canonical =~ s/[^A-Za-z0-9]+/_/g; $canonical =~ tr/A-Z/a-z/; return join '', _indent(2, ''), _indent(2, '

', $header, '

'), "\n"; } sub a($$) { my($tag, $attribute, $text) = @_; _link($text, $attribute->{href}); } sub resume { my($tag, $attribute, $text, %meta) = @_; my $author = $meta{author} if exists $meta{author} && $meta{author}; my $email = $meta{email} if exists $meta{email} && $meta{email}; my $author_email = $author && $email ? join '', $author, ' (', $email, ')' : $author || $email; $author = $email if $email && !$author; my $moremeta; foreach(qw(keywords)) { $moremeta .= qq( \n) if exists $meta{$_} && $meta{$_}; } return << " EndHTML"; $author Resume $moremeta $text EndHTML } sub author { my($tag, $attribute, $text) = @_; return '' unless $text; my $href = $attribute->{href}; return join '', qq(
\n), _indent(3, '

', _link($text, $href), '

'); } sub address { my($tag, $attribute, $text) = @_; return '' unless $text; return join '', _indent(3, $text), "
\n\n"; } sub school { my($tag, $attribute, $text) = @_; my($name, $location, $href) = map { $attribute->{$_} } qw(name location href); return join '', _indent(2, '

', _link($name, $href), '

'), _indent(2, '
', $location, '
'), "\n", _indent(2, '

', $text, '

'), "\n"; } sub employer { my($tag, $attribute, $text) = @_; my($name, $location, $dates, $position, $href) = map { $attribute->{$_} } qw(name location dates position href); return join '', _indent(2, '

', _link($name, $href), '

'), _indent(2, '
', $location, '
'), _indent(2, '
', $dates, '
'), "\n", _indent( 2, '

', $position, '. ', $text, '

' ), "\n"; } sub skill { my($tag, $attribute, $text) = @_; return '' unless $text; return _indent(3, join $text, '
  • ', '
  • '); } sub references { my($tag, $attribute, $text) = @_; return '' unless $text; return _indent(2, '

    ', $text, '

    ') . "\n"; } sub _link($$) { my $text = shift || return ''; my $href = shift; $href ? $href =~ /^mailto\:/ ? qq($text) : qq($text) : $text ; } sub _indent { my($indent, @text) = @_; return '' unless @text; $indent = '' unless defined $indent; $indent = ' ' x $indent if $indent =~ /^\d+$/; return wrap($indent, $indent . ' ', join '', @text) . "\n"; } 1;