diff --git a/lib/Text/Dokuwiki/Render/Markdown.pm b/lib/Text/Dokuwiki/Render/Markdown.pm index 7ac6ecd..bc94b95 100644 --- a/lib/Text/Dokuwiki/Render/Markdown.pm +++ b/lib/Text/Dokuwiki/Render/Markdown.pm @@ -117,4 +117,28 @@ sub codeblock { 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;