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 "((") { elsif ($match eq "((") {
push @{ $self->{footnotes} }, $self->_parse_text($content); push @{ $self->{footnotes} }, $self->_parse_text($content);
my $n = scalar @{ $self->{footnotes} }; my $n = scalar @{ $self->{footnotes} };
push @parts, [a => {href => "#note_$n", class => 'footnote'}, $n]; push @parts, [fn_ref => {}, $n];
next; next;
} }
elsif ($match) { die("parser failed, unrecognized inline: $match\n"); } elsif ($match) { die("parser failed, unrecognized inline: $match\n"); }
@ -296,10 +296,8 @@ sub parse {
my @fn = @{ $self->{footnotes} }; my @fn = @{ $self->{footnotes} };
my @out = (); my @out = ();
for (my $i = 0; $i <= $#fn; $i++) { for (my $i = 0; $i <= $#fn; $i++) {
my $name = sprintf "note_%d", $i + 1; push @tree, [footnote => {number => $i + 1}, $fn[$i]];
push @out, [li => {}, [a => {name => $name}], $fn[$i]];
} }
push @tree, [ol => {}, @out];
} }
return [div => {}, @tree ]; 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); 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 { sub blockquote {
my ($self, $attrs, $content) = @_; my ($self, $attrs, $content) = @_;

Loading…
Cancel
Save