File Coverage

blib/lib/App/Greple/xlate/Filter.pm
Criterion Covered Total %
statement 11 25 44.0
branch n/a
condition n/a
subroutine 4 8 50.0
pod 0 2 0.0
total 15 35 42.8


line stmt bran cond sub pod time code
1             package App::Greple::xlate::Filter;
2              
3 1     1   2071 use v5.26;
  1         4  
4 1     1   6 use warnings;
  1         3  
  1         76  
5 1     1   6 use Data::Dumper;
  1         3  
  1         64  
6              
7 1     1   6 use Exporter 'import';
  1         2  
  1         720  
8             our @EXPORT = qw(lineify_colon lineify_cm);
9              
10             my %RE = (
11             LANG => qr/ORIGINAL|\w\w(-\w\w)?/,
12             );
13              
14             ##
15             ## Convert to line-by-line output if only part of a line is being translated
16             ##
17             ## * At this time, if a line contains more than one target area,
18             ## it results in being split across multiple lines.
19             ##
20              
21             sub lineify_colon {
22 0     0 0   local $_ = do { local $/; <> };
  0            
  0            
23 0           _colon();
24 0           print;
25             }
26             sub _colon {
27 0     0     s{
28             (^|\G)
29             (?
 (?

.+)?) (? :{7,}) \s+ (? ($RE{LANG})) \n

30             (? .+) \g{mark} \n
31             \g{mark} \s+ (? ($RE{LANG})) \n
32             (? .+) \g{mark} \n
33             (? (?(

) ((?!:{7}).)* | ((?!:{7}).)+ )) \n?

34             }{
35 0           <<~EOF;
36             $+{mark} $+{l1}
37             $+{pre}$+{t1}$+{post}
38             $+{mark}
39             $+{mark} $+{l2}
40             $+{pre}$+{t2}$+{post}
41             $+{mark}
42             EOF
43             }xnmge;
44             }
45              
46             sub lineify_cm {
47 0     0 0   local $_ = do { local $/; <> };
  0            
  0            
48 0           _cm();
49 0           print;
50             }
51             sub _cm {
52 0     0     s{
53             (^|\G)
54             (?
 (?

.+)?) (? <<<<<<<) \s+ (? ($RE{LANG})) \n

55             (? .+) (? =======) \n
56             (? .+) (? >>>>>>>) \s+ (? ($RE{LANG})) \n
57             (? (?(

) ((?!<<<<<<<).)* | ((?!<<<<<<<).)+ )) \n?

58             }{
59 0           <<~EOF;
60             $+{m1} $+{l1}
61             $+{pre}$+{t1}$+{post}
62             $+{m2}
63             $+{pre}$+{t2}$+{post}
64             $+{m3} $+{l2}
65             EOF
66             }xnmge;
67             }
68              
69             1;