wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / vcard.pl
blob3ce69ff31aa5e174da51b7d5db767651ad43d3fd
1 # We just try to autodetect everything.
3 push(@MyRules, \&hCardRule);
5 my $addr = qr(\G(\S+ \S+)
6 (.*)
7 ((?:[A-Z][A-Z]?-)?\d+) (.*)(?:
8 (.*))?
12 my $email = qr(\G\s*(\S+@\S+)\n?);
14 my $tel = qr(\G\s*(\S+): (\+?[-0-9 ]+)\n?);
16 sub hCardRule {
17 return undef unless $bol;
18 my ($fn, $street, $zip, $city, $country) = /$addr/cg;
19 if ($fn) {
20 my ($mail) = /$email/cg;
21 my ($phonetype, $phone) = /$tel/cg;
22 my $html = $q->span({-class=>'fn'}, $fn) . $q->br();
23 $html .= $q->span({-class=>'street-address'}, $street) . $q->br();
24 $html .= $q->span({-class=>'postal-code'}, $zip)
25 . ' ' . $q->span({-class=>'locality'}, $city);
26 $html .= $q->br()
27 . $q->span({-class=>'country-name'}, $country) if $country;
28 my $hCard = $q->p($html);
29 $html = '';
30 $html .= $q->span({-class=>'email'},
31 $q->a({-href=>'mailto:' . $mail}, $mail)) if $mail;
32 $html .= $q->br() if $mail and $phone;
33 $html .= $q->span({-class=>'tel'},
34 $q->span({-class=>'type'}, $phonetype) . ': '
35 . $q->span({-class=>'value'}, $phone)) if $phone;
36 $hCard .= $q->p($html) if $html;
37 $hCard = $q->div({-class=>'vcard',
38 -style=>'color:red;'}, $hCard);
39 return CloseHtmlEnvironments() . $hCard . AddHtmlEnvironment('p');
41 return undef;