|
|
|
@ -6,7 +6,9 @@ use utf8;
|
|
|
|
|
|
|
|
|
|
sub new { |
|
|
|
|
my ($class) = @_; |
|
|
|
|
my $self = {}; |
|
|
|
|
my $self = { |
|
|
|
|
footnotes => [], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return bless($self, $class); |
|
|
|
|
} |
|
|
|
@ -203,7 +205,12 @@ sub _parse_text {
|
|
|
|
|
elsif ($match eq "__") { %attrs = ('text-decoration' => 'underline'); } |
|
|
|
|
elsif ($match eq "{{") { push @parts, $self->_parse_include($content); next; } |
|
|
|
|
elsif ($match eq "[[") { push @parts, $self->_parse_link($content); next; } |
|
|
|
|
elsif ($match eq "((") { ...; next; } |
|
|
|
|
elsif ($match eq "((") { |
|
|
|
|
push @{ $self->{footnotes} }, $self->_parse_text($content); |
|
|
|
|
my $n = scalar @{ $self->{footnotes} }; |
|
|
|
|
push @parts, [sup => {}, [a => {href => "#note_$n"}, $n]]; |
|
|
|
|
next; |
|
|
|
|
} |
|
|
|
|
elsif ($match) { die("unrecognized inline: $match\n"); } |
|
|
|
|
|
|
|
|
|
if (%attrs) { |
|
|
|
@ -320,6 +327,15 @@ sub parse {
|
|
|
|
|
printf "Unmatched % 3d: %s\n", $linenum, $line; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (scalar @{ $self->{footnotes} }) { |
|
|
|
|
my @fn = @{ $self->{footnotes} }; |
|
|
|
|
my @out = (); |
|
|
|
|
for (my $i = 0; $i <= $#fn; $i++) { |
|
|
|
|
push @out, [li => {}, [a => {name => "note_" . $i + 1}], $fn[$i]]; |
|
|
|
|
} |
|
|
|
|
push @tree, [ol => {}, @out]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return [div => {}, @tree ]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|