Browse Source

+ file/nowiki block

master
Zubrikhin Alexey 10 years ago
parent
commit
b6544fc92a
  1. 27
      lib/Text/Dokuwiki.pm

27
lib/Text/Dokuwiki.pm

@ -25,9 +25,17 @@ sub parse {
$linenum++; $linenum++;
given ($mode) { given ($mode) {
when ("codeblk") { when (m!block/(file|code|nowiki)!o) {
if ($line =~ m{^\s*</code>}o) { if ($line =~ m{^\s*</$1>}o) {
push @{ $tree }, [code => $attrs, 0 => $buf]; if ($1 eq 'file') {
my $dt = [dt => {}, 0 => $attrs->{file}];
my $dd = [dt => {}, 0 => [pre => {class => $attrs->{class}}, 0 => $buf]];
push @{ $tree }, [dl => {class => 'file'}, [$dt, $dd]];
} elsif ($1 eq 'nowiki') {
push @{ $tree }, [pre => {}, 0 => $buf];
} else {
push @{ $tree }, [code => {class => $attrs->{class}}, 0 => $buf];
}
($buf, $attrs, $mode) = ('', {}, undef); next; ($buf, $attrs, $mode) = ('', {}, undef); next;
} }
$buf .= $line . "\n"; $buf .= $line . "\n";
@ -63,10 +71,15 @@ sub parse {
push @{ $tree }, ["h$level" => {}, 0 => $2]; push @{ $tree }, ["h$level" => {}, 0 => $2];
next; next;
} }
# code block # code/file block
when (m/^\s?<code\s*(\S+)?>\s*$/o) { when (m/^\s?<(code|file)(?:\s+(\S+)\s+(\S+))?>\s*$/o) {
$attrs = ($2) ? {class => $2} : {}; $mode = "block/$1";
$mode = "codeblk"; $attrs = ($2) ? {class => $2, file => $3} : {};
next;
}
# nowiki block
when (m/\s?<nowiki>/o) {
$mode = "block/nowiki";
next; next;
} }
# lists # lists

Loading…
Cancel
Save