line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package oEdtk::TexTag;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.08';
|
4
|
|
|
|
|
|
|
my $_FLAG_DIGITS = 1;
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# A SIMPLE OBJECT THAT DESCRIBES A TEX TAG.
|
8
|
|
|
|
|
|
|
sub new {
|
9
|
0
|
|
|
0
|
0
|
|
my ($class, $name, $val) = @_;
|
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $ref = ref($val);
|
12
|
0
|
0
|
0
|
|
|
|
if ($ref ne '' && $ref ne 'ARRAY' && $ref ne 'HASH' && $ref ne 'oEdtk::TexDoc') {
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
13
|
0
|
|
|
|
|
|
die "ERROR: Unexpected value type, must be a scalar or an oEdtk::TexDoc object\n";
|
14
|
|
|
|
|
|
|
}
|
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
0
|
|
|
|
if ($name =~ /\d/ && $_FLAG_DIGITS) {
|
17
|
0
|
|
|
|
|
|
warn "INFO : Tex Tag name cannot contain digits : $name !\n";
|
18
|
0
|
|
|
|
|
|
warn "INFO : further messages for Tex Tag containing digits will be ignored\n";
|
19
|
0
|
|
|
|
|
|
$_FLAG_DIGITS = 0;
|
20
|
|
|
|
|
|
|
}
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $self = {
|
23
|
|
|
|
|
|
|
name => $name,
|
24
|
|
|
|
|
|
|
value => $val
|
25
|
|
|
|
|
|
|
};
|
26
|
0
|
|
|
|
|
|
bless $self, $class;
|
27
|
|
|
|
|
|
|
# warn "INFO : objet TexTag $self créé...\n";
|
28
|
0
|
|
|
|
|
|
return $self;
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub emit {
|
33
|
0
|
|
|
0
|
0
|
|
my ($self) = @_;
|
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
0
|
|
|
|
if (defined $self->{'name'} && $self->{'name'}=~/^_include_$/){
|
36
|
0
|
|
|
|
|
|
return "\\input{" . $self->{'value'} . "\}";
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# A tag containing a scalar value or an HASH/ARRAY/TexDoc object.
|
40
|
0
|
0
|
|
|
|
|
if (defined $self->{'value'}) {
|
41
|
0
|
|
|
|
|
|
my $ref = ref($self->{'value'});
|
42
|
0
|
|
|
|
|
|
my $name = $self->{'name'};
|
43
|
|
|
|
|
|
|
# A list of values.
|
44
|
0
|
0
|
|
|
|
|
if ($ref eq 'ARRAY') {
|
45
|
0
|
|
|
|
|
|
my $macro = "\\edListNew{$self->{'name'}}";
|
46
|
0
|
|
|
|
|
|
foreach (@{$self->{'value'}}) {
|
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# my $val = escape($_);
|
48
|
0
|
|
|
|
|
|
my $val = oEdtk::TexDoc::escape($_); # NOT CLEAN !
|
49
|
|
|
|
|
|
|
# warn "INFO : Appel à oEdtk::Doc::escape dans TexTag $val\n";
|
50
|
0
|
|
|
|
|
|
$macro .= "\\edListAdd{$self->{'name'}}{$val}";
|
51
|
|
|
|
|
|
|
}
|
52
|
0
|
|
|
|
|
|
return $macro;
|
53
|
|
|
|
|
|
|
}
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# A tag containing other tags.
|
56
|
0
|
|
|
|
|
|
my $value = $self->{'value'};
|
57
|
0
|
0
|
|
|
|
|
if ($ref eq 'HASH') {
|
58
|
0
|
|
|
|
|
|
my $inner = oEdtk::TexDoc->new();
|
59
|
0
|
|
|
|
|
|
while (my ($key, $val) = each %{$self->{'value'}}) {
|
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$inner->append($key, $val);
|
61
|
|
|
|
|
|
|
}
|
62
|
0
|
|
|
|
|
|
$value = $inner;
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Escape if we have a scalar value.
|
66
|
0
|
0
|
|
|
|
|
if (ref($value) eq '') {
|
67
|
0
|
|
|
|
|
|
$value =~ s/\s+/ /g;
|
68
|
|
|
|
|
|
|
# $value = escape($value);
|
69
|
0
|
|
|
|
|
|
$value = oEdtk::TexDoc::escape($value);
|
70
|
|
|
|
|
|
|
# warn "INFO : Appel à oEdtk::Doc::escape dans TexTag $value\n";
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return "\\long\\gdef\\$name\{$value\}";
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
# A command call.
|
76
|
0
|
|
|
|
|
|
return "\\$self->{'name'}";
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
1
|
|
7
|
use oEdtk::Config (config_read);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
81
|
1
|
|
|
1
|
|
5
|
use oEdtk::Dict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
274
|
|
82
|
|
|
|
|
|
|
my $_CFG = config_read();
|
83
|
|
|
|
|
|
|
# ON OUVRE LE DICTIONNAIRE EN STATIQUE POUR ÉVITER LES ACCÈS MULTIPLES AU FICHIER CORRESPONDANT
|
84
|
|
|
|
|
|
|
my $_DICO_CHAR = oEdtk::Dict->new($_CFG->{'EDTK_DICO_XLAT'}, , { section => 'LATEX' });
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# http://woufeil.developpez.com/tutoriels/perl/poo/
|
87
|
|
|
|
|
|
|
sub escape_0 { # NOT CLEAN passer par l'héritage ! TexTag->TexDoc
|
88
|
0
|
|
|
0
|
0
|
|
my $str = shift;
|
89
|
|
|
|
|
|
|
# ESCAPE SPECIAL CARACTERS FOR TEXTAGS
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Deal with backslashes and curly braces first and at the same
|
92
|
|
|
|
|
|
|
# time, because escaping backslashes introduces curly braces, and,
|
93
|
|
|
|
|
|
|
# inversely, escaping curly braces introduces backslashes.
|
94
|
|
|
|
|
|
|
# see http://detexify.kirelabs.org/classify.html
|
95
|
0
|
|
|
|
|
|
my $new = '';
|
96
|
0
|
|
|
|
|
|
foreach my $s (split(/([{}\\])/, $str)) {
|
97
|
0
|
0
|
|
|
|
|
if ($s eq "{") {
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$new .= "\\textbraceleft{}";
|
99
|
|
|
|
|
|
|
} elsif ($s eq "}") {
|
100
|
0
|
|
|
|
|
|
$new .= "\\textbraceright{}";
|
101
|
|
|
|
|
|
|
} elsif ($s eq "\\") {
|
102
|
0
|
|
|
|
|
|
$new .= "\\textbackslash{}";
|
103
|
|
|
|
|
|
|
} else {
|
104
|
0
|
|
|
|
|
|
$new .= $s;
|
105
|
|
|
|
|
|
|
}
|
106
|
|
|
|
|
|
|
}
|
107
|
0
|
|
|
|
|
|
$new =~s/([%&\$_#])/\\$1/g;
|
108
|
|
|
|
|
|
|
# warn "INFO : \$_DICO_CHAR = $_DICO_CHAR\n";
|
109
|
|
|
|
|
|
|
# xxx la ligne qui suit provoque une erreur après la fin de programme
|
110
|
|
|
|
|
|
|
# $new = $_DICO_CHAR->substitue($new);
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# \\"{} => PROVOQUE DES ERREURS TEX DANS LE PROCESSUS D'INDEXATION (POUR INJECTION EN SGBD)
|
113
|
0
|
|
|
|
|
|
$new =~ s/\\\"\{\}/\\textquotestraightdblbase{}/g;
|
114
|
0
|
|
|
|
|
|
$new =~ s/\\\"/\\textquotestraightdblbase{}/g;
|
115
|
|
|
|
|
|
|
# 01...@A...yz{}|~ 1°
|
116
|
0
|
|
|
|
|
|
return $new;
|
117
|
|
|
|
|
|
|
}
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#END {
|
121
|
|
|
|
|
|
|
# undef $_DICO_CHAR;
|
122
|
|
|
|
|
|
|
# undef $_CFG;
|
123
|
|
|
|
|
|
|
# warn "INFO : Objet TexTag supprimé !\n";
|
124
|
|
|
|
|
|
|
#}
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |