From 3327e647991e905db9f4554c7cc016615f7e6af7 Mon Sep 17 00:00:00 2001 From: Zubrikhin Alexey Date: Mon, 20 Jul 2015 14:49:13 +1000 Subject: [PATCH] * change footnotes handling --- lib/Text/Dokuwiki/Parser.pm | 6 ++---- lib/Text/Dokuwiki/Render/Markdown.pm | 11 +++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Text/Dokuwiki/Parser.pm b/lib/Text/Dokuwiki/Parser.pm index 1fee818..582dcac 100644 --- a/lib/Text/Dokuwiki/Parser.pm +++ b/lib/Text/Dokuwiki/Parser.pm @@ -217,7 +217,7 @@ sub _parse_text { elsif ($match eq "((") { push @{ $self->{footnotes} }, $self->_parse_text($content); my $n = scalar @{ $self->{footnotes} }; - push @parts, [a => {href => "#note_$n", class => 'footnote'}, $n]; + push @parts, [fn_ref => {}, $n]; next; } elsif ($match) { die("parser failed, unrecognized inline: $match\n"); } @@ -296,10 +296,8 @@ sub parse { my @fn = @{ $self->{footnotes} }; my @out = (); for (my $i = 0; $i <= $#fn; $i++) { - my $name = sprintf "note_%d", $i + 1; - push @out, [li => {}, [a => {name => $name}], $fn[$i]]; + push @tree, [footnote => {number => $i + 1}, $fn[$i]]; } - push @tree, [ol => {}, @out]; } return [div => {}, @tree ]; diff --git a/lib/Text/Dokuwiki/Render/Markdown.pm b/lib/Text/Dokuwiki/Render/Markdown.pm index bc94b95..e5d3210 100644 --- a/lib/Text/Dokuwiki/Render/Markdown.pm +++ b/lib/Text/Dokuwiki/Render/Markdown.pm @@ -89,6 +89,17 @@ sub img { return sprintf("![%s](%s%s)", $alt, $attrs->{src}, $title); } +sub fn_ref { + my ($self, $attr, $content) = @_; + return "[^$content]"; +} + +sub footnote { + my ($self, $attrs, $content) = @_; + + return "[^$attrs->{number}]: " . $self->treewalk($content) . "\n"; +} + sub blockquote { my ($self, $attrs, $content) = @_;