File Coverage

blib/lib/TeX/Encode/BibTeX.pm
Criterion Covered Total %
statement 8 28 28.5
branch 0 12 0.0
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 15 51 29.4


line stmt bran cond sub pod time code
1             package TeX::Encode::BibTeX;
2              
3             our $VERSION = '2.009'; # VERSION
4              
5 4     4   81 use 5.008;
  4         14  
6 4     4   24 use strict;
  4         8  
  4         84  
7              
8             #use AutoLoader qw(AUTOLOAD);
9              
10 4     4   19 use TeX::Encode;
  4         8  
  4         1560  
11              
12             our @ISA = qw(Encode::Encoding);
13              
14             __PACKAGE__->Define(qw(BibTeX bibtex));
15              
16             # encode($self, $string [,$check])
17             sub encode
18             {
19 0     0 1   my( undef, $string, $check ) = @_;
20              
21 0           my $tex = "";
22              
23 0           pos($string) = 0;
24              
25 0           for($string)
26             {
27 0           while(1) {
28 0 0         last if pos($_) == length($_);
29              
30 0 0         /\G($TeX::Encode::charmap::BIBTEX_RESERVED_RE)/gc and ($tex .= $TeX::Encode::charmap::BIBTEX_RESERVED{$1}, next);
31              
32             # BibTeX requires extra braces around any LaTeX mark-up
33             # (we assume anything we substitute with will be BibTeX-safe)
34 0 0         /\G($TeX::Encode::charmap::CHAR_MAP_RE)/gc and ($tex .= '{'.$TeX::Encode::charmap::CHAR_MAP{$1}.'}', next);
35              
36             # basic unreserved characters
37 0 0         /\G([\sa-zA-Z0-9\.,:;'"\(\)=\-\/\[\]\*\+!]+)/gc and ($tex .= $1, next);
38 0 0         /\G([\x00-\x7e])/gc and ($tex .= $1, next);
39              
40 0 0         /\G(.)/gc and ($tex .= '?', next);
41              
42 0           Carp::confess "Shouldn't happen";
43             }
44             }
45              
46 0           return $tex;
47             }
48              
49             # encode_url($self, $string [,$check])
50             sub encode_url
51             {
52 0     0 1   my( undef, $str, $check ) = @_;
53              
54             # replace braces/slash (URL???) and underscore with their URI escape points
55 0           $str =~ s/([\{\}\\_])/sprintf("%%%02x",ord($1))/seg;
  0            
56 0           $str =~ s/(%)/$TeX::Encode::charmap::BIBTEX_RESERVED{$1}/sg;
57              
58 0           return $str;
59             }
60              
61             # decode($octets [,$check])
62             sub decode
63             {
64 0     0 1   return &TeX::Encode::decode;
65             }
66              
67 0     0 1   sub perlio_ok { 0 }
68              
69             # Autoload methods go after =cut, and are processed by the autosplit program.
70              
71             1;
72             __END__