Browse Source

* Text::Dokuwiki::Parser : 'given/when' still experimental

master
Alex 'AdUser' Z 9 years ago
parent
commit
53706e81eb
  1. 14
      lib/Text/Dokuwiki/Parser.pm

14
lib/Text/Dokuwiki/Parser.pm

@ -222,8 +222,7 @@ sub parse {
foreach my $line (@lines) {
$linenum++;
given ($mode) {
when (m!block/(file|code|nowiki)!o) {
if ($mode =~ m!block/(file|code|nowiki)!o) {
$buf //= [];
if ($line =~ m{^\s*</$1>}o) {
$buf = join("\n", @{ $buf });
@ -240,24 +239,21 @@ sub parse {
}
push @{ $buf }, $line;
next;
}
when ("code") {
} elsif ($mode eq 'code') {
if ($line =~ m/^\s{2}(.+)/o) {
$buf .= $line . "\n";
next;
}
push @tree, [pre => {}, $buf];
($buf, $mode, $attrs) = ('', '', {});
}
when ("list") {
} elsif ($mode eq 'list') {
if ($line =~ m/^(\s{2})+([\*-])\s+(.+)/o) {
push @{ $buf }, $line;
next;
}
push @tree, $self->_parse_list($buf);
($buf, $mode, $attrs) = ('', '', {});
}
when ("table") {
} elsif ($mode eq 'table') {
if ($line =~ m/^\s?[\|\^]/o) {
push @{ $buf }, $line;
next;
@ -265,8 +261,6 @@ sub parse {
push @tree, $self->_parse_table($buf);
($buf, $mode, $attrs) = ('', '', {});
}
}
given ($line) {
# macro

Loading…
Cancel
Save