Browse Source

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

master
Alex 'AdUser' Z 10 years ago
parent
commit
184ee1f7d0
  1. 30
      lib/Text/Dokuwiki/Parser.pm

30
lib/Text/Dokuwiki/Parser.pm

@ -177,13 +177,11 @@ sub _parse_text {
last;
}
given ($match) {
when ('\\ ') { # force newline
if ($match eq '\\ ') { # force newline
push @parts, [br => {}];
$line = $after;
next;
}
default {
} elsif ($match) {
$endtag = $inlines->{$match};
$endpos = index($after, $endtag, 0);
if ($endpos < 0) { # no closing marker?
@ -193,24 +191,18 @@ sub _parse_text {
}
$content = substr($after, 0, $endpos);
$line = substr($after, $endpos + 2);
continue;
}
}
my %attrs;
given ($match) {
when ("//") { %attrs = ('font-style' => 'italic'); }
when ("**") { %attrs = ('font-weight' => 'bold'); }
when ("''") { %attrs = ('font-family' => 'monospace'); }
when ("__") { %attrs = ('text-decoration' => 'underline'); }
when ("{{") { push @parts, $self->_parse_include($content); next; }
when ("[[") { push @parts, $self->_parse_link($content); next; }
when ("((") { ...; next; }
default {
die("unrecognized inline: $match\n");
next;
}
}
if ($match eq "//") { %attrs = ('font-style' => 'italic'); }
elsif ($match eq "**") { %attrs = ('font-weight' => 'bold'); }
elsif ($match eq "''") { %attrs = ('font-family' => 'monospace'); }
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) { die("unrecognized inline: $match\n"); }
if (%attrs) {
push @parts, [span => \%attrs, $self->_parse_text($content)];
next;

Loading…
Cancel
Save