| 1 | package Serge::Engine::Plugin::parse_dtd; | ||||||||||
| 2 | 1 | ▶ | use parent Serge::Engine::Plugin::Base::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | sub name { | ||||||||||
| 7 | 0 | ▶ | return '.dtd entities parser plugin'; | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | sub parse { | ||||||||||
| 11 | 0 | ▶ | my ($self, $textref, $callbackref, $lang) = @_; | ||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | die 'callbackref not specified' unless $callbackref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | |||||||||||
| 15 | # Finding translatable strings in file | ||||||||||
| 16 | |||||||||||
| 17 | # Format is: | ||||||||||
| 18 | # <!ENTITY hint "text"> | ||||||||||
| 19 | |||||||||||
| 20 | 0 | my $translated_text = $$textref; | |||||||||
| 21 | |||||||||||
| 22 | 0 | $translated_text =~ s|(<!ENTITY\s+)([\w\-\.]+)(\s*"\s*)(.*?)(\s*"\s*>)|$1.$2.$3.$self->parse_callback($callbackref, $4, undef, $2, undef, $lang, $2).$5|sgie; | |||||||||
| 23 | |||||||||||
| 24 | 0 | return $translated_text; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub parse_callback { | ||||||||||
| 28 | 0 | ▶ | my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang, $key) = @_; | ||||||||
|
Subroutine
parse_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 29 | |||||||||||
| 30 | 0 | $string =~ s/'/'/g; | |||||||||
| 31 | 0 | $string =~ s/"/"/g; | |||||||||
| 32 | 0 | $string =~ s/"/"/g; | |||||||||
| 33 | 0 | $string =~ s/#/#/g; | |||||||||
| 34 | 0 | $string =~ s/&/&/g; | |||||||||
| 35 | |||||||||||
| 36 | 0 | my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang, $key); | |||||||||
| 37 | |||||||||||
| 38 | 0 | $translated_string =~ s/\#/__HASH__/g; | |||||||||
| 39 | 0 | $translated_string =~ s/\&/__AMP__/g; | |||||||||
| 40 | 0 | $translated_string =~ s/\'/'/g; | |||||||||
| 41 | 0 | $translated_string =~ s/\"/"/g; | |||||||||
| 42 | 0 | $translated_string =~ s/__HASH__/#/g; | |||||||||
| 43 | 0 | $translated_string =~ s/__AMP__/&/g; | |||||||||
| 44 | |||||||||||
| 45 | 0 | return $translated_string; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 1 | 1; | |||||||||