Browse Source

* change footnotes handling

master
Zubrikhin Alexey 10 years ago
parent
commit
3327e64799
  1. 6
      lib/Text/Dokuwiki/Parser.pm
  2. 11
      lib/Text/Dokuwiki/Render/Markdown.pm

6
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 ];

11
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) = @_;

Loading…
Cancel
Save