diff --git a/lib/Text/Dokuwiki/Parser.pm b/lib/Text/Dokuwiki/Parser.pm index c91c794..1fc54c7 100644 --- a/lib/Text/Dokuwiki/Parser.pm +++ b/lib/Text/Dokuwiki/Parser.pm @@ -177,40 +177,32 @@ sub _parse_text { last; } - given ($match) { - when ('\\\\ ') { # force newline - push @parts, [br => {}]; + if ($match eq '\\\\ ') { # force newline + push @parts, [br => {}]; + $line = $after; + next; + } elsif ($match) { + $endtag = $inlines->{$match}; + $endpos = index($after, $endtag, 0); + if ($endpos < 0) { # no closing marker? + push @parts, $match; $line = $after; next; } - default { - $endtag = $inlines->{$match}; - $endpos = index($after, $endtag, 0); - if ($endpos < 0) { # no closing marker? - push @parts, $match; - $line = $after; - next; - } - $content = substr($after, 0, $endpos); - $line = substr($after, $endpos + 2); - continue; - } + $content = substr($after, 0, $endpos); + $line = substr($after, $endpos + 2); } 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;