Browse Source

* handlers for <table>, <tr>, <th>, <td>

master
Zubrikhin Alexey 9 years ago
parent
commit
daefa360b3
  1. 24
      lib/Text/Dokuwiki/Render/Markdown.pm

24
lib/Text/Dokuwiki/Render/Markdown.pm

@ -117,4 +117,28 @@ sub codeblock {
return $out; return $out;
} }
sub table {
my ($self, $attrs, $content) = @_;
return $content . "\n";
}
sub tr {
my ($self, $attrs, $content) = @_;
return "|" . $content . "\n";
}
sub _cell {
my ($self, $attrs, $content) = @_;
my $cs = $attrs->{colspan} || 1;
my ($pl, $pr); # read as: padding left/right
unless ($attrs->{align}) { ($pl, $pr) = ('', ''); }
elsif ($attrs->{align} eq 'center') { ($pl, $pr) = (" ", " "); }
elsif ($attrs->{align} eq 'left') { ($pl, $pr) = ("", " "); }
elsif ($attrs->{align} eq 'right') { ($pl, $pr) = (" ", ""); }
return $pl . $content . $pr . ("|" x $cs);
}
sub td { my $self = shift; $self->_cell(@_); }
sub th { my $self = shift; $self->_cell(@_); }
1; 1;

Loading…
Cancel
Save