From daefa360b3f259d7b5cc1202280bd3f369603fc0 Mon Sep 17 00:00:00 2001 From: Zubrikhin Alexey Date: Mon, 20 Jul 2015 12:09:44 +1000 Subject: [PATCH] * handlers for , ,
, --- lib/Text/Dokuwiki/Render/Markdown.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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;