dyndoc-ruby-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/dyndoc/.DS_Store +0 -0
- data/dyndoc/Dyn/.postload +1 -0
- data/dyndoc/Dyn/.preload +1 -0
- data/dyndoc/Dyn/After.dyn +3 -0
- data/dyndoc/Dyn/Base.dyn +18 -0
- data/dyndoc/Dyn/Minimum.dyn +20 -0
- data/dyndoc/Model/Html/DefaultPost_html.dyn +5 -0
- data/dyndoc/Model/Html/DefaultPre_html.dyn +15 -0
- data/dyndoc/Model/Odt/DefaultPost_content.xml +3 -0
- data/dyndoc/Model/Odt/DefaultPost_tmpl_content.xml +3 -0
- data/dyndoc/Model/Odt/DefaultPre_content.xml +8 -0
- data/dyndoc/Model/Odt/DefaultPre_tmpl_content.xml +8 -0
- data/dyndoc/Model/Tex/ContentPost_tmpl.tex +1 -0
- data/dyndoc/Model/Tex/ContentPre_tmpl.tex +6 -0
- data/dyndoc/Model/Tex/DefaultPost_tmpl.tex +73 -0
- data/dyndoc/Model/Tex/DefaultPre_tmpl.tex +16 -0
- data/dyndoc/Model/Ttm/DefaultPost_tmpl.ttm +3 -0
- data/dyndoc/Model/Ttm/DefaultPre_tmpl.ttm +16 -0
- data/dyndoc/Std/Array.dyn +96 -0
- data/dyndoc/Std/Composer.dyn +38 -0
- data/dyndoc/Std/DevTag.dyn +101 -0
- data/dyndoc/Std/DynVar.dyn +23 -0
- data/dyndoc/Std/File.dyn +55 -0
- data/dyndoc/Std/Git.dyn +34 -0
- data/dyndoc/Std/List.dyn +46 -0
- data/dyndoc/Std/OOP.dyn +32 -0
- data/dyndoc/Std/Signal.dyn +18 -0
- data/dyndoc/Std/String.dyn +22 -0
- data/dyndoc/Std/Styles.dyn +1 -0
- data/dyndoc/Std/Test.dyn +282 -0
- data/dyndoc/Std/Utils.dyn +42 -0
- data/dyndoc/Std/Verb.dyn +5 -0
- data/dyndoc/Style/Notation/Math.dyn +7 -0
- data/dyndoc/Style/Notation/Stat/Classic.dyn +8 -0
- data/dyndoc/Style/Notation/Stat/Cqls.dyn +44 -0
- data/dyndoc/Style/Text/Std.dyn +5 -0
- data/dyndoc/Style/Text/StdAlias.dyn +3 -0
- data/dyndoc/Style/Text/StdTex.dyn +17 -0
- data/dyndoc/Style/Text/Txt.dyn +1 -0
- data/dyndoc/Tex/.postload +1 -0
- data/dyndoc/Tex/.preload +1 -0
- data/dyndoc/Tex/10pt_tmpl.tex +1 -0
- data/dyndoc/Tex/11pt_tmpl.tex +1 -0
- data/dyndoc/Tex/12pt_tmpl.tex +1 -0
- data/dyndoc/Tex/Article_tmpl.tex +1 -0
- data/dyndoc/Tex/Beamer.dyn_tex +35 -0
- data/dyndoc/Tex/BeamerHandout_tmpl.tex +2 -0
- data/dyndoc/Tex/Book_tmpl.tex +1 -0
- data/dyndoc/Tex/DefaultFirst_tmpl.tex +1 -0
- data/dyndoc/Tex/DefaultLast_tmpl.tex +8 -0
- data/dyndoc/Tex/Default_tmpl.tex +9 -0
- data/dyndoc/Tex/First_tmpl.tex +8 -0
- data/dyndoc/Tex/Fr_tmpl.tex +17 -0
- data/dyndoc/Tex/Header_tmpl.tex +3 -0
- data/dyndoc/Tex/InclGraph_tmpl.tex +19 -0
- data/dyndoc/Tex/InclSpatProc_tmpl.tex +70 -0
- data/dyndoc/Tex/InclSumMI_tmpl.tex +4 -0
- data/dyndoc/Tex/LargeA4_tmpl.tex +5 -0
- data/dyndoc/Tex/Last_tmpl.tex +1 -0
- data/dyndoc/Tex/Option_tmpl.tex +8 -0
- data/dyndoc/Tex/Png_tmpl.tex +1 -0
- data/dyndoc/Tex/RefCite2_tmpl.tex +16 -0
- data/dyndoc/Tex/RefCite_tmpl.tex +16 -0
- data/dyndoc/Tex/Report_tmpl.tex +1 -0
- data/dyndoc/Tex/Theorem_tmpl.tex +14 -0
- data/dyndoc/Tools/.DS_Store +0 -0
- data/dyndoc/Tools/Atom.dyn/index.dyn +42 -0
- data/dyndoc/Tools/AtomDyndocker.dyn/index.dyn +43 -0
- data/dyndoc/Tools/R/Fig.dyn +144 -0
- data/dyndoc/Tools/R/Tools.dyn +344 -0
- data/dyndoc/Tools/Tex/Beamer.dyn +204 -0
- data/dyndoc/Tools/Tex/BeamerSlide.dyn_tex +199 -0
- data/dyndoc/Tools/Tex/Pgf.dyn +115 -0
- data/dyndoc/Tools/Tex/Table.dyn +278 -0
- data/dyndoc/Tools/Tex/Tools.dyn +37 -0
- data/dyndoc/Tools/Tex/Verb.dyn +77 -0
- data/dyndoc/Tools/Web/.DS_Store +0 -0
- data/dyndoc/Tools/Web/Ace.dyn +54 -0
- data/dyndoc/Tools/Web/Code.dyn +129 -0
- data/dyndoc/Tools/Web/DHtmlX.dyn +39 -0
- data/dyndoc/Tools/Web/DataTable.dyn_html +354 -0
- data/dyndoc/Tools/Web/Html.dyn +286 -0
- data/dyndoc/Tools/Web/Html/JQuery.dyn +123 -0
- data/dyndoc/Tools/Web/Html/Styles.dyn +4 -0
- data/dyndoc/Tools/Web/JQueryTools.dyn +87 -0
- data/dyndoc/Tools/Web/Layout.dyn +86 -0
- data/dyndoc/Tools/Web/Layout/CQLS.dyn +6 -0
- data/dyndoc/Tools/Web/Layout/LJK.dyn +41 -0
- data/dyndoc/Tools/Web/TabBar.dyn +37 -0
- data/dyndoc/Tools/Web/Ttm.dyn +20 -0
- data/dyndoc/Tools/Web/Txtl.dyn +14 -0
- data/lib/dyndoc-core.rb +59 -0
- data/lib/dyndoc/base/envir.rb +541 -0
- data/lib/dyndoc/base/filter/call.rb +127 -0
- data/lib/dyndoc/base/filter/filter_mngr.rb +637 -0
- data/lib/dyndoc/base/filter/server.rb +882 -0
- data/lib/dyndoc/base/filters.rb +3 -0
- data/lib/dyndoc/base/helpers.rb +9 -0
- data/lib/dyndoc/base/helpers/core.rb +32 -0
- data/lib/dyndoc/base/helpers/parser.rb +188 -0
- data/lib/dyndoc/base/scanner.rb +886 -0
- data/lib/dyndoc/base/tags.rb +4 -0
- data/lib/dyndoc/base/tags/keys_mngr.rb +401 -0
- data/lib/dyndoc/base/tags/part_tag.rb +194 -0
- data/lib/dyndoc/base/tags/tag_mngr.rb +125 -0
- data/lib/dyndoc/base/tags/user_tag.rb +216 -0
- data/lib/dyndoc/base/tmpl.rb +6 -0
- data/lib/dyndoc/base/tmpl/eval.rb +581 -0
- data/lib/dyndoc/base/tmpl/extension.rb +337 -0
- data/lib/dyndoc/base/tmpl/manager.rb +450 -0
- data/lib/dyndoc/base/tmpl/oop.rb +57 -0
- data/lib/dyndoc/base/tmpl/parse_do.rb +2446 -0
- data/lib/dyndoc/base/tmpl/rbenvir.rb +54 -0
- data/lib/dyndoc/base/utils.rb +367 -0
- data/lib/dyndoc/common/dynArray.rb +234 -0
- data/lib/dyndoc/common/file.rb +52 -0
- data/lib/dyndoc/common/init.rb +2 -0
- data/lib/dyndoc/common/tilt.rb +149 -0
- data/lib/dyndoc/common/utils.rb +61 -0
- data/lib/dyndoc/common/uv.rb +163 -0
- data/lib/dyndoc/init/config.rb +296 -0
- data/lib/dyndoc/init/home.rb +9 -0
- data/lib/dyndoc/plugins/tex.rb +4 -0
- data/lib/dyndoc/plugins/tex/beamer.rb +208 -0
- data/lib/dyndoc/plugins/tex/tex_eval.rb +69 -0
- data/lib/dyndoc/plugins/tex/tex_parse_do.rb +25 -0
- data/lib/dyndoc/plugins/tex/tex_user_tag.rb +32 -0
- data/share/R/dyndocMsys2.R +5 -0
- data/share/R/dyndocTools.R +9 -0
- data/share/R/test.R +14 -0
- data/share/R/tools/dynArray.R +34 -0
- data/share/R/tools/dynCapture.R +84 -0
- data/share/R/tools/dynMsys2.R +54 -0
- data/share/julia/dynArray.jl +93 -0
- data/share/julia/dyndoc.jl +110 -0
- data/share/julia/ruby.jl +37 -0
- metadata +202 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
module Dyndoc
|
|
2
|
+
|
|
3
|
+
class CallFilter
|
|
4
|
+
|
|
5
|
+
######################
|
|
6
|
+
## Common useful part
|
|
7
|
+
######################
|
|
8
|
+
|
|
9
|
+
def CallFilter.init(tmpl,calls,args,meths)
|
|
10
|
+
@@tmpl,@@calls,@@args,@@meths=tmpl,calls,args,meths
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def CallFilter.parseArgs(call,args,isMeth=nil)
|
|
14
|
+
call2= (call[-1,1]=="!" ? call[0...-1] : call) #TODO: pas de "!" à la fin normalement!
|
|
15
|
+
names=@@args[call2].dup if @@args[call2]
|
|
16
|
+
names=names[1..-1] if names and isMeth
|
|
17
|
+
#puts "parseArgs:call,args,names";p call2;p args; p names
|
|
18
|
+
args.map!{|e|
|
|
19
|
+
v,k,o,t=e.scan(/(:?)([#{FilterManager.letters}]*)\s*(=?>?)(.*)/).flatten
|
|
20
|
+
#p [v,k,o,t]
|
|
21
|
+
if o=="=" ## name=value
|
|
22
|
+
":"+k.strip+"=>"+t
|
|
23
|
+
elsif v==":" and !o.empty? ## :name => value
|
|
24
|
+
e
|
|
25
|
+
elsif names and names.length==1 and names[0][-1,1]=="*"
|
|
26
|
+
":"+names[0]+"=>"+e
|
|
27
|
+
elsif names ##no named with names
|
|
28
|
+
#puts "names";p call;p names; p e
|
|
29
|
+
p "No enough named parameter!!!" if names.empty?
|
|
30
|
+
":"+(names.shift)+"=>"+e
|
|
31
|
+
else ##no named witout names
|
|
32
|
+
e
|
|
33
|
+
end
|
|
34
|
+
}
|
|
35
|
+
args.map!{|e| e.split("\n")}.flatten!
|
|
36
|
+
#puts "parseArgs:args";p args
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def CallFilter.isMeth?(call)
|
|
40
|
+
@@meths.include? call
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def CallFilter.argsMeth(call,b)
|
|
44
|
+
meth_args_b=nil
|
|
45
|
+
if @@meths.include? call
|
|
46
|
+
meth_args_b=b[1..-1] #for the called method
|
|
47
|
+
b=b[0,1]
|
|
48
|
+
end
|
|
49
|
+
#puts "argsMeth";p call;p b;p meth_args_b
|
|
50
|
+
return [b,meth_args_b]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def CallFilter.output(w,filter)
|
|
54
|
+
if w[0,1]=="\\"
|
|
55
|
+
w[1..-1]
|
|
56
|
+
else
|
|
57
|
+
call,args,rest=w.split(/\((.*)\)/)
|
|
58
|
+
#p call;p args;p rest
|
|
59
|
+
if args
|
|
60
|
+
call,args=call[2,call.length-2],args.split(/\||@/).map{|e| e.strip}
|
|
61
|
+
else
|
|
62
|
+
call,args=call[2,call.length-3],[]
|
|
63
|
+
end
|
|
64
|
+
#puts "call,args";p call; p args
|
|
65
|
+
args,meth_args=CallFilter.argsMeth(call,args)
|
|
66
|
+
#puts "call2,args,meth_args";p call;p args;p meth_args
|
|
67
|
+
CallFilter.parseArgs(call,args)
|
|
68
|
+
#puts "call3,args";p call;p args
|
|
69
|
+
res2=@@tmpl.eval_CALL(call,args,filter,meth_args)
|
|
70
|
+
#puts "res2";p res2
|
|
71
|
+
res2
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
###########################
|
|
76
|
+
## Useful for old dyn!
|
|
77
|
+
###########################
|
|
78
|
+
|
|
79
|
+
require 'strscan'
|
|
80
|
+
@@scan=StringScanner.new("")
|
|
81
|
+
@@start=/\\?@[\{\[]/;
|
|
82
|
+
@@start2={"{"=>/\{/,"["=>/\[/}
|
|
83
|
+
@@stop={"{"=>/\}@?/,"["=>/\]@?/}
|
|
84
|
+
|
|
85
|
+
def CallFilter.token(txt)
|
|
86
|
+
@@scan.string=txt
|
|
87
|
+
@@scan.pos=0
|
|
88
|
+
deb=nil
|
|
89
|
+
while @@scan.scan_until(@@start)
|
|
90
|
+
##p @@scan.matched;p @@scan.matched.length
|
|
91
|
+
m=@@scan.matched
|
|
92
|
+
deb=@@scan.pos-(m.length)
|
|
93
|
+
end
|
|
94
|
+
return nil unless deb
|
|
95
|
+
|
|
96
|
+
i=0
|
|
97
|
+
m=m[-1,1]
|
|
98
|
+
while (r0=@@scan.exist?(@@stop[m])) and (r1=@@scan.exist?(@@start2[m])) and (r1<r0)
|
|
99
|
+
@@scan.scan_until(@@start2[m])
|
|
100
|
+
i+=1
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
begin
|
|
104
|
+
i-=1
|
|
105
|
+
@@scan.scan_until(@@stop[m])
|
|
106
|
+
fin=@@scan.pos - (@@scan.matched.length)
|
|
107
|
+
end while i>=0
|
|
108
|
+
return [deb,fin]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def CallFilter.filter(str,filter)
|
|
112
|
+
res=str.dup
|
|
113
|
+
##p res
|
|
114
|
+
deb=nil
|
|
115
|
+
begin
|
|
116
|
+
deb,fin=CallFilter.token(res)
|
|
117
|
+
if deb
|
|
118
|
+
##p res[deb..fin]
|
|
119
|
+
res[deb..fin]= CallFilter.output(res[deb..fin],filter)
|
|
120
|
+
end
|
|
121
|
+
end while deb
|
|
122
|
+
res
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Dyndoc
|
|
4
|
+
|
|
5
|
+
class FilterManager
|
|
6
|
+
|
|
7
|
+
attr_accessor :envir, :rbEnvir, :rEnvir, :outType, :tmpl
|
|
8
|
+
|
|
9
|
+
@@letters="_,\\-,\\.,\\@,\\$,\\&,\\%,a-z,0-9,A-Z,à,é,è,ë,ù,ü,ö"
|
|
10
|
+
@@letters_short="_,\\-,\\.,a-z,0-9,A-Z,à,é,è,ë,ù,ü,ö"
|
|
11
|
+
@@start,@@stop="\\{","\\}"
|
|
12
|
+
|
|
13
|
+
def FilterManager.letters(mode=nil)
|
|
14
|
+
return @@letters unless mode
|
|
15
|
+
return @@letters_short if mode==:short
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def FilterManager.delim
|
|
19
|
+
[@@start,@@stop]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def initialize(envir={},tmpl=nil) #rbEnvir=nil,rEnvir=nil
|
|
23
|
+
@envir=Envir.new(envir)
|
|
24
|
+
@tmpl=tmpl
|
|
25
|
+
@rbEnvir=@tmpl.rbEnvir
|
|
26
|
+
@rEnvir=@tmpl.rEnvir
|
|
27
|
+
@scan=CallScanner.new
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def FilterManager.global(tmpl)
|
|
32
|
+
FilterManager.new({:local=>tmpl.global,:global=>tmpl.global},tmpl)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
@@options={:required=>:default,:stack=>:post, :mark=>:post, "G"=> :global,"L"=>:local, :prev=>:out,"O"=>:out, :frag =>:pre, "-"=>:pre,"+"=>:post,"?"=>:default}
|
|
36
|
+
|
|
37
|
+
def delim=(s)
|
|
38
|
+
case s
|
|
39
|
+
when "{"
|
|
40
|
+
@@start,@@stop="\\{","\\}"
|
|
41
|
+
when "["
|
|
42
|
+
@@start,@@stop="\\[","\\]"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# READ AND IMPORT VARIABLES! ##############
|
|
48
|
+
|
|
49
|
+
######################
|
|
50
|
+
# read ordered dict
|
|
51
|
+
######################
|
|
52
|
+
def FilterManager.eval_options(opts)
|
|
53
|
+
opts=":local" unless opts
|
|
54
|
+
if opts.scan(/^([A-Z\d\?]*[+]?[-]?)$/)[0]
|
|
55
|
+
## Abbreviation
|
|
56
|
+
opts=opts.split("").map{|l| @@options[l]}
|
|
57
|
+
else
|
|
58
|
+
opts=opts.split(",").map{|e| eval(e)}
|
|
59
|
+
## alias
|
|
60
|
+
opts.map!{|e| (@@options[e] ? @@options[e] : e)}
|
|
61
|
+
end
|
|
62
|
+
return opts
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def FilterManager.eval_dict(b,vars=false)
|
|
66
|
+
#puts "eval_dict:b";p b
|
|
67
|
+
dict=[]
|
|
68
|
+
key=nil
|
|
69
|
+
first_lines=vars
|
|
70
|
+
newarray=[]
|
|
71
|
+
b.each{|s|
|
|
72
|
+
if first_lines
|
|
73
|
+
## list of variables (only for VARS not for CALL and INPUT)
|
|
74
|
+
res=s.split(",").map{|e| e.strip.scan(/^(\:\:?[\w\._]*\*?)(?:\[(.*)\])?$/)[0]}
|
|
75
|
+
if res.all?
|
|
76
|
+
res.map{|k,o|
|
|
77
|
+
o=FilterManager.eval_options(o)
|
|
78
|
+
k.strip!
|
|
79
|
+
if k[0,2]=="::"
|
|
80
|
+
k=k[1..-1]
|
|
81
|
+
o << :global
|
|
82
|
+
end
|
|
83
|
+
if k[-1,1]=="*"
|
|
84
|
+
k=k[0...-1]
|
|
85
|
+
o << :array
|
|
86
|
+
newarray << eval(k)
|
|
87
|
+
end
|
|
88
|
+
dict << [eval(k).to_s,["",o]]
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
first_lines=false
|
|
92
|
+
end
|
|
93
|
+
else
|
|
94
|
+
first_lines=false
|
|
95
|
+
end
|
|
96
|
+
unless first_lines
|
|
97
|
+
## variables initialisation ?
|
|
98
|
+
key,opts,out,str=s.scan(/^\s*\:(\:?[#{FilterManager.letters}\-\._]*\*?)(?:\[(.*)\])?\s*=(=?)>(.*)/)[0]
|
|
99
|
+
#puts "key";p key
|
|
100
|
+
if key
|
|
101
|
+
opts.strip! if opts
|
|
102
|
+
opts=FilterManager.eval_options(opts)
|
|
103
|
+
if key[0,1]==":"
|
|
104
|
+
key=key[1..-1]
|
|
105
|
+
opts << :global
|
|
106
|
+
end
|
|
107
|
+
if key[-1,1]=="*"
|
|
108
|
+
key=key[0...-1]
|
|
109
|
+
opts << :array
|
|
110
|
+
newarray << key
|
|
111
|
+
end
|
|
112
|
+
opts << :out unless out.empty? ## "==>" means that opts includes :out
|
|
113
|
+
str.strip!
|
|
114
|
+
## test if string
|
|
115
|
+
tmp=str.scan(/^[\"\'](.*)[\"\']$/)[0]
|
|
116
|
+
#p tmp
|
|
117
|
+
str=(tmp ? tmp[0] : str)
|
|
118
|
+
elt=[str,opts] ## always an Array
|
|
119
|
+
dict << [key,elt]
|
|
120
|
+
else
|
|
121
|
+
## append the line
|
|
122
|
+
#puts "append the line";p s
|
|
123
|
+
dict[-1][1][0] += ((dict[-1][1][0]=="") ? "" : "\n")+s
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
}
|
|
127
|
+
##
|
|
128
|
+
dict2=[]
|
|
129
|
+
dict.each{|k,v|
|
|
130
|
+
if (newarray.include? k)
|
|
131
|
+
if(elt=dict2.assoc(k))
|
|
132
|
+
elt[1][0] << v[0]
|
|
133
|
+
elt[1][1] |= v[1]
|
|
134
|
+
else
|
|
135
|
+
dict2 << [k,[[v[0]],v[1]]]
|
|
136
|
+
end
|
|
137
|
+
else
|
|
138
|
+
dict2 << [k,v]
|
|
139
|
+
end
|
|
140
|
+
}
|
|
141
|
+
#deal with whitespace at the beginning and the end of a block!
|
|
142
|
+
dict2.each{|k,v| v[0]=Utils.unprotect_blocktext(v[0]) unless v[0].is_a? Array}
|
|
143
|
+
dict2
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
########################
|
|
147
|
+
# import ordered dict to final one!
|
|
148
|
+
########################
|
|
149
|
+
def import_dict(dict)
|
|
150
|
+
#puts "import_dict:dict";p dict
|
|
151
|
+
dict.each{|k,v|
|
|
152
|
+
#puts "import_dict:k,v";p k;p v
|
|
153
|
+
if k.is_a? Symbol
|
|
154
|
+
@envir.local[k]=v #for :prev
|
|
155
|
+
#elsif k.is_a? String and k[0,1]=="@"
|
|
156
|
+
#ruby variables
|
|
157
|
+
#puts "#{k}";p v
|
|
158
|
+
#p @envir.local
|
|
159
|
+
#TODO: evaluer la variable en tenant compte de la valuer :default!
|
|
160
|
+
# environnement objet! accessor objet!
|
|
161
|
+
elsif k.is_a? String
|
|
162
|
+
if v[1] and v[1].include? :array
|
|
163
|
+
v[0].map!{|e| e.replace(apply(e))}
|
|
164
|
+
else
|
|
165
|
+
v[0].replace(apply(v[0]))
|
|
166
|
+
end
|
|
167
|
+
key=k.to_s
|
|
168
|
+
key=@envir.keyMeth(key)
|
|
169
|
+
#puts "import_dict:key=#{key}"
|
|
170
|
+
## key=toto.1.ta -> key=toto et deps=["1","ta"]
|
|
171
|
+
keys=Envir.to_keys(key)
|
|
172
|
+
#puts "import_dict:keys,v";p keys;p v
|
|
173
|
+
opts=v[1] & [:global,:local,:out]
|
|
174
|
+
## declaration
|
|
175
|
+
v[1] -= opts ## always [:global,:local,:out] have to be deleted
|
|
176
|
+
v=v[0,1] if v[1].empty? ## no option v Array of length 1
|
|
177
|
+
## set the env
|
|
178
|
+
#p opts
|
|
179
|
+
if opts.include? :out
|
|
180
|
+
@envir.keys_defined?(keys,:out) ##find the previous
|
|
181
|
+
#p self
|
|
182
|
+
#p @envir.curenv.__id__;p @envir.local.__id__; p @envir.global.__id__
|
|
183
|
+
env=@envir.curenv
|
|
184
|
+
elsif opts.include? :global
|
|
185
|
+
env=@envir.global
|
|
186
|
+
else ## the default is local!!!
|
|
187
|
+
env=@envir.local
|
|
188
|
+
end
|
|
189
|
+
## deal with v[0]
|
|
190
|
+
#puts "keys v";p keys;p v
|
|
191
|
+
## not necessarily a textElt!!!! -> curEnv2 is returned by @envir.elt_defined?(keys2)!
|
|
192
|
+
curEnv2=nil
|
|
193
|
+
if v[0].is_a? String and v[0].strip[0,1]==":" and (!(keys[-1].is_a? String) or !["@","$"].include? keys[-1][-1,1]) #and !("0".."9").include?(v[0].strip[1,1])
|
|
194
|
+
#puts "keys";p keys
|
|
195
|
+
#puts "v[0]";p v[0];p v[0].strip[1..-1]
|
|
196
|
+
keys2=v[0].strip[1..-1]
|
|
197
|
+
keys2="self"+keys2 if keys2[0,1]=="."
|
|
198
|
+
keys2=Envir.to_keys(keys2)
|
|
199
|
+
#puts "keys2:";p keys2
|
|
200
|
+
keys2,key_extract=Envir.extraction_make(keys2)
|
|
201
|
+
#p @envir
|
|
202
|
+
curEnv2=@envir.elt_defined?(keys2)
|
|
203
|
+
#puts "curEnv2"; p curEnv2
|
|
204
|
+
elsif v[0].is_a? String and v[0].strip[0,2]=='\:'
|
|
205
|
+
v[0]=v[0].strip[1..-1]
|
|
206
|
+
end
|
|
207
|
+
## correction 12/10/08: attr was unfortunately lost for pointer argument!!!!
|
|
208
|
+
#puts "import_dict:v (AV)";p v
|
|
209
|
+
if curEnv2
|
|
210
|
+
#puts "v[1]?";p v
|
|
211
|
+
curAttr=(v[1] ? v[1] : nil)
|
|
212
|
+
v=Envir.extraction_apply(curEnv2[keys2[-1]],key_extract)
|
|
213
|
+
v[:attr]=curAttr if curAttr
|
|
214
|
+
#puts "v";p v
|
|
215
|
+
else
|
|
216
|
+
v=Envir.to_textElt(v)
|
|
217
|
+
#special treatment for ruby variable here
|
|
218
|
+
#puts "vvvvvvvv";p k;p v
|
|
219
|
+
if k[-1,1]=="@"
|
|
220
|
+
v[:rb]=@rbEnvir[0].eval(v[:val][0])
|
|
221
|
+
end
|
|
222
|
+
if k[-1,1]=="$"
|
|
223
|
+
rname=".dynStack$rb"+v.object_id.abs.to_s
|
|
224
|
+
v[:r]=R4rb::RVector.new rname
|
|
225
|
+
#p k;p v
|
|
226
|
+
v[:r] << rname
|
|
227
|
+
R4rb << rname+"<-"+ v[:val][0]
|
|
228
|
+
end
|
|
229
|
+
if k[-1,1]=="&"
|
|
230
|
+
jlname="_dynStack_"+v.object_id.abs.to_s
|
|
231
|
+
v[:jl]=Julia::Vector.new jlname
|
|
232
|
+
#p k;p v
|
|
233
|
+
v[:jl] << jlname
|
|
234
|
+
Julia << "("+jlname+"="+ v[:val][0]+")"
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
if k[-1,1]=="%"
|
|
238
|
+
cmdCode=v[:val][0]
|
|
239
|
+
args=case cmdCode
|
|
240
|
+
when /^jl\:/
|
|
241
|
+
[cmdCode[3..-1],:jl]
|
|
242
|
+
when /^(r|R)\:/
|
|
243
|
+
[cmdCode[2..-1],:r]
|
|
244
|
+
else
|
|
245
|
+
[@rbEnvir[0].eval(cmdCode),:rb]
|
|
246
|
+
end
|
|
247
|
+
## Dyndoc.warn "args",args
|
|
248
|
+
v[:rb]=Dyndoc::Vector.new([:r,:jl],args[0],args[1],k[0...-1])
|
|
249
|
+
#p k;p v
|
|
250
|
+
#v[:rb].replace @rbEnvir[0]eval(v[:val][0])
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
#special treatment for null array and hash
|
|
254
|
+
if v.is_a? Hash and v[:val] and ["0[]","0{}"].include? v[:val][0].strip
|
|
255
|
+
v[:val][0].strip!
|
|
256
|
+
v=( v[:val][0][1,1]=="[" ? [] : {} )
|
|
257
|
+
end
|
|
258
|
+
#puts "import_dict:v (AP)";p v
|
|
259
|
+
#p Envir.elt_defined?(env,keys)
|
|
260
|
+
#puts "keys";p keys
|
|
261
|
+
#puts "env";p env
|
|
262
|
+
## deal with eventual changes
|
|
263
|
+
curEnv=Envir.elt_defined?(env,keys)
|
|
264
|
+
#puts "curEnv";p curEnv
|
|
265
|
+
#puts "v";p v
|
|
266
|
+
if curEnv and !(v.is_a? Array) and !(v[:attr] and v[:attr].include? :default)
|
|
267
|
+
curElt=curEnv[keys[-1]]
|
|
268
|
+
#puts "curElt";p curElt
|
|
269
|
+
## key already exists
|
|
270
|
+
if Envir.is_textElt?(curElt)
|
|
271
|
+
curElt[:attr]=v[:attr] if v[:attr] #change the options (maybe dangerous)
|
|
272
|
+
if curElt[:attr] and curElt[:attr].include? :post
|
|
273
|
+
## append the content (this is an ANCHOR!!!)
|
|
274
|
+
curElt[:val][0] << "\n" unless curElt[:val][0].empty?
|
|
275
|
+
curElt[:val][0]+=v[:val][0]
|
|
276
|
+
else
|
|
277
|
+
## change the content
|
|
278
|
+
Envir.update_textElt(curElt,v)
|
|
279
|
+
end
|
|
280
|
+
elsif Envir.is_listElt?(curElt)
|
|
281
|
+
#puts "keys";p keys
|
|
282
|
+
#change it! curElt is here curEnv!
|
|
283
|
+
#curEnv.each{|k,e| if k!=:prev
|
|
284
|
+
# puts "curEnv(AV)[#{k}]";p e
|
|
285
|
+
# end
|
|
286
|
+
#}
|
|
287
|
+
#puts "curElt(AV)";p curElt
|
|
288
|
+
#puts "keys2";p keys2
|
|
289
|
+
#puts "v";p v
|
|
290
|
+
#curElt=v
|
|
291
|
+
curEnv[keys[-1]]=v
|
|
292
|
+
#puts "curElt(AP)";p curElt
|
|
293
|
+
#curEnv.each{|k,e| if k!=:prev
|
|
294
|
+
#puts "curEnv(AP)[#{k}]";p e
|
|
295
|
+
# end
|
|
296
|
+
#}
|
|
297
|
+
end
|
|
298
|
+
elsif v.is_a? Hash and v[:attr] and (v[:attr].include? :default)
|
|
299
|
+
## This is the old tricks!!!
|
|
300
|
+
## unless (env==@envir.local and @envir.key_defined?(keys[0])) or (env.include? keys[0] and !env[keys[0]][0].empty?)
|
|
301
|
+
## This is the new one!
|
|
302
|
+
# if (env==@envir.local) and !(Envir.elt_defined?(@envir.local,keys))
|
|
303
|
+
# BUT this does not work for CoursProba because of RFig with rcode empty!
|
|
304
|
+
# last try: direct adaptation of the old one without further thinking!
|
|
305
|
+
if !(env==@envir.local and @envir.elt_defined?(keys)) and !((tmpElt=Envir.elt_defined?(env,keys,true)) and !tmpElt[:val][0].empty?)
|
|
306
|
+
v[:attr] -= [:default]
|
|
307
|
+
v.delete(:attr) if v[:attr].empty?
|
|
308
|
+
## create it
|
|
309
|
+
Envir.set_elt!(env,keys,v)
|
|
310
|
+
end
|
|
311
|
+
else
|
|
312
|
+
## otherwise, create it
|
|
313
|
+
#p "ici";p keys;p v
|
|
314
|
+
|
|
315
|
+
curElt=Envir.get_elt!(env,keys)
|
|
316
|
+
curElt[keys[-1]]=v if curElt
|
|
317
|
+
#Envir.set_elt!(env,keys,v)
|
|
318
|
+
end
|
|
319
|
+
#puts "import_dict";p curElt
|
|
320
|
+
end
|
|
321
|
+
}
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
=begin
|
|
326
|
+
###############################
|
|
327
|
+
# mode -> nil (normal), :pre (fragment to preprocess), :post (post-processed)
|
|
328
|
+
###############################
|
|
329
|
+
def apply(str,mode=nil,to_filter=true,escape=false)
|
|
330
|
+
#puts "Filter:apply:str->";p str
|
|
331
|
+
@mode=mode
|
|
332
|
+
str=str.gsub(/\\?\#?\##{@@start}[#{@@letters}]+#{@@stop}/) {|w|
|
|
333
|
+
if w[0,1]=="\\"
|
|
334
|
+
w[1..-1]
|
|
335
|
+
else
|
|
336
|
+
@envir.output(w,mode,escape)
|
|
337
|
+
end
|
|
338
|
+
}
|
|
339
|
+
if @rbEnvir and @mode!=:pre
|
|
340
|
+
str=RbServer.filter(str,@rbEnvir)
|
|
341
|
+
end
|
|
342
|
+
## very important!! multilines have to be splitted -> flatten is applied just after!!!
|
|
343
|
+
## obsolete : str=str.split("\n") if @@start=="\\[" and !str.empty? # "".split("\n") -> [] and not [""]
|
|
344
|
+
str=str.split("\n") if @mode==:pre and !str.empty?
|
|
345
|
+
res=(to_filter ? RServer.filter(CallFilter.filter(str,self)) : str)
|
|
346
|
+
#puts "res";p res
|
|
347
|
+
res
|
|
348
|
+
end
|
|
349
|
+
=end
|
|
350
|
+
|
|
351
|
+
def process(txt,in_type=nil,out_type=nil)
|
|
352
|
+
#puts "process:txt";p txt;p in_type
|
|
353
|
+
return txt[1..-1] if txt[0,1]=="\\"
|
|
354
|
+
txt2=txt[(in_type.length+1)..-2] if in_type
|
|
355
|
+
out_type=@outType unless out_type
|
|
356
|
+
out_type="none" unless out_type
|
|
357
|
+
if ["="].include? txt2[0,1]
|
|
358
|
+
#p txt2
|
|
359
|
+
out_type+="="
|
|
360
|
+
#p out_type
|
|
361
|
+
txt2=txt2[1..-1]
|
|
362
|
+
end
|
|
363
|
+
@current=txt2
|
|
364
|
+
#puts "txt2";p txt2
|
|
365
|
+
#p out_type
|
|
366
|
+
case in_type
|
|
367
|
+
when ":",":rb",":Rb","#rb","#Rb"
|
|
368
|
+
return txt if @mode==:pre or !@rbEnvir[0]
|
|
369
|
+
@tmpl.process_rb(txt2)
|
|
370
|
+
res=RbServer.output(txt2,@rbEnvir[0])
|
|
371
|
+
#Dyndoc.warn "process [rb]",res #,txt2,@rbEnvir[0],@tmpl.rbenvir_ls(@rbEnvir[0])] if txt2=~/\\\\be/
|
|
372
|
+
#Dyndoc.warn "#rb", [@rbEnvir[0],$curDyn.tmpl.rbenvir_current,$curDyn.tmpl.rbenvir_get($curDyn.tmpl.rbenvir_current[0])] if txt2=="toto[i]"
|
|
373
|
+
when ":R","#R"
|
|
374
|
+
return txt if @mode==:pre
|
|
375
|
+
res=RServer.safe_output(txt2,@rEnvir[0])
|
|
376
|
+
if res[0]=='try-error'
|
|
377
|
+
puts "WARNING: #{txt} was not properly evaluated!" if Dyndoc.cfg_dyn[:ruby_mode]!=:expression
|
|
378
|
+
$dyn_logger.write("ERROR R: #{txt} was not properly evaluated!\n") unless Dyndoc.cfg_dyn[:dyndoc_mode]==:normal
|
|
379
|
+
res=txt
|
|
380
|
+
end
|
|
381
|
+
#puts "#{txt} in #{@rEnvir[0]} is #{res}"
|
|
382
|
+
when ":r","#r"
|
|
383
|
+
return txt if @mode==:pre
|
|
384
|
+
res=RServer.safe_output(txt2,@rEnvir[0],:pretty=>true)
|
|
385
|
+
if res[0]=='try-error'
|
|
386
|
+
puts "WARNING: #{txt} was not properly evaluated!" if Dyndoc.cfg_dyn[:ruby_mode]!=:expression
|
|
387
|
+
$dyn_logger.write("ERROR R: #{txt} was not properly evaluated!\n") unless Dyndoc.cfg_dyn[:dyndoc_mode]==:normal
|
|
388
|
+
res=txt
|
|
389
|
+
end
|
|
390
|
+
#puts "#{txt} in #{@rEnvir[0]} is #{res}"
|
|
391
|
+
when ":jl","#jl"
|
|
392
|
+
return txt if @mode==:pre
|
|
393
|
+
## puts "#jl:"+txt2
|
|
394
|
+
res=JLServer.output(txt2,:print=>nil)
|
|
395
|
+
when "@"
|
|
396
|
+
return txt if @mode==:pre
|
|
397
|
+
res=CallFilter.output(txt,self)
|
|
398
|
+
when "#","##"
|
|
399
|
+
#p @envir
|
|
400
|
+
#p @envir.output(txt,@mode,@escape)
|
|
401
|
+
#p @envir.output(in_type+"{"+txt2+"}",@mode,@escape)
|
|
402
|
+
#puts "txxt2";p txt2
|
|
403
|
+
if txt2[-1,1]=="?"
|
|
404
|
+
if res=@envir.extract(txt2[0...-1]) and res.class==String
|
|
405
|
+
#nothing else to do! res is
|
|
406
|
+
#p res
|
|
407
|
+
else
|
|
408
|
+
res=""
|
|
409
|
+
end
|
|
410
|
+
elsif txt2[0,1]=="#" #fetch the length of the list
|
|
411
|
+
res=@envir.extract(txt2[1..-1])
|
|
412
|
+
#Dyndoc.warn "\#{#{txt2}\}",res
|
|
413
|
+
res=(res ? res.length : -1)
|
|
414
|
+
#res=-1;in_type+"{"+txt2+"}"
|
|
415
|
+
elsif txt2[0,1]=="?"
|
|
416
|
+
res=@envir.extract(txt2[1..-1]).class
|
|
417
|
+
#puts "#{txt2[1..-1]}";p res
|
|
418
|
+
out_type+="=" unless out_type[-1,1]=="="
|
|
419
|
+
if res==Hash
|
|
420
|
+
res=:List
|
|
421
|
+
elsif res==Array
|
|
422
|
+
res=:Array
|
|
423
|
+
elsif res==String
|
|
424
|
+
res=:Text
|
|
425
|
+
else
|
|
426
|
+
res=:nil
|
|
427
|
+
end
|
|
428
|
+
#p res
|
|
429
|
+
elsif txt2[0,2]=="+?"
|
|
430
|
+
res=@envir.extract(txt2[2..-1])
|
|
431
|
+
out_type+="=" unless out_type[-1,1]=="="
|
|
432
|
+
res=(res and res.length>0 ? true : false)
|
|
433
|
+
elsif txt2[0,2]=="0?"
|
|
434
|
+
res=@envir.extract(txt2[2..-1])
|
|
435
|
+
out_type+="=" unless out_type[-1,1]=="="
|
|
436
|
+
res=(res and res.length==0 ? true : false)
|
|
437
|
+
elsif /([^@]+@)([^@]*)/ =~ txt2
|
|
438
|
+
#puts "ICI";p txt2;p @envir.local;p @envir.extract_raw($1)
|
|
439
|
+
res=@envir.extract_raw($1)[:rb]
|
|
440
|
+
#p res
|
|
441
|
+
res=eval("res"+$2) if $2
|
|
442
|
+
#p res
|
|
443
|
+
elsif /([^\$]+\$)([^\$]*)/ =~ txt2 ##and !(txt2.include? "{") #deal with R variable
|
|
444
|
+
#puts "ICI";p txt2
|
|
445
|
+
#p $1;p @envir.extract_raw($1);p $2
|
|
446
|
+
#if @envir.extract_raw($1)
|
|
447
|
+
res= ( $2.empty? ? @envir.extract_raw($1)[:r].value : (@envir.extract_raw($1)[:r].name+$2).to_R )
|
|
448
|
+
#else
|
|
449
|
+
# return txt
|
|
450
|
+
#end
|
|
451
|
+
#TO CHANGE!!! res=eval("res"+$2) if $2 #TO CHANGE!!!!
|
|
452
|
+
#puts "res R";p res
|
|
453
|
+
elsif /([^\&]+\&)([^\&]*)/ =~ txt2 ##and !(txt2.include? "{") #deal with R variable
|
|
454
|
+
#puts "ICI";p txt2
|
|
455
|
+
## p "jl";p $1;p $2 ;p @envir.extract_raw($1)
|
|
456
|
+
#if @envir.extract_raw($1)
|
|
457
|
+
res= ( $2.empty? ? @envir.extract_raw($1)[:jl].value : (@envir.extract_raw($1)[:jl].name+$2).to_jl )
|
|
458
|
+
#else
|
|
459
|
+
# return txt
|
|
460
|
+
#end
|
|
461
|
+
#TO CHNAGE!!! res=eval("res"+$2) if $2 #TO CHANGE!!!!
|
|
462
|
+
#puts "res R";p res
|
|
463
|
+
elsif /([^\%]+\%)([^\%]*)/ =~ txt2 ##and !(txt2.include? "{") #deal with R variable
|
|
464
|
+
#puts "ICI";p txt2
|
|
465
|
+
## p "dynArray";p $1;p $2 ;p @envir.extract_raw($1)
|
|
466
|
+
#if @envir.extract_raw($1)
|
|
467
|
+
res= ( $2.empty? ? @envir.extract_raw($1)[:rb].ary : (@envir.extract_raw($1)[:rb].ary+$2) )
|
|
468
|
+
#else
|
|
469
|
+
# return txt
|
|
470
|
+
#end
|
|
471
|
+
#TO CHNAGE!!! res=eval("res"+$2) if $2 #TO CHANGE!!!!
|
|
472
|
+
#puts "res R";p res
|
|
473
|
+
elsif /^([#{FilterManager.letters}]*)\>([#{FilterManager.letters}]*)$/ =~ txt2
|
|
474
|
+
#puts "var>output"
|
|
475
|
+
var,out=$1,$2
|
|
476
|
+
out="out" if out.empty?
|
|
477
|
+
out=out.to_sym
|
|
478
|
+
out_type+="=" unless out_type[-1,1]=="="
|
|
479
|
+
var=@envir.extract_raw(var)
|
|
480
|
+
res=var[out]
|
|
481
|
+
elsif txt2[-1,1]=="!"
|
|
482
|
+
#p "!=exec mode"
|
|
483
|
+
inRb,name=txt2[0...-1].split(":")
|
|
484
|
+
name,inRb=inRb,name unless name
|
|
485
|
+
inRb="new" if inRb and inRb.empty?
|
|
486
|
+
#puts "name,inRb";p [name,inRb]
|
|
487
|
+
code=@envir.extract(name)
|
|
488
|
+
#p code
|
|
489
|
+
if code
|
|
490
|
+
Utils.escape_delim!(code)
|
|
491
|
+
code="{#document][#main]"+code+"[#}"
|
|
492
|
+
#p code
|
|
493
|
+
@tmpl.rbenvir_go_to(inRb)
|
|
494
|
+
res=@tmpl.parse(code,self)
|
|
495
|
+
@tmpl.rbenvir_back_from(inRb)
|
|
496
|
+
else
|
|
497
|
+
res=txt2
|
|
498
|
+
end
|
|
499
|
+
#p res
|
|
500
|
+
else
|
|
501
|
+
txt2=txt2[0...-1]+tmpl.Fmt if txt2[-1,1]=="#"
|
|
502
|
+
#p txt2
|
|
503
|
+
#depend on out_type!
|
|
504
|
+
if [":=",":rb=",":Rb=","#rb=","#Rb=",":r=",":R=","#r=","#R="].include? out_type
|
|
505
|
+
#ruby use!
|
|
506
|
+
res=@envir.extract(txt2)
|
|
507
|
+
else
|
|
508
|
+
#otherwise
|
|
509
|
+
###puts "iciiii";p txt;p txt2
|
|
510
|
+
###if txt2.include? "{"
|
|
511
|
+
### res=txt
|
|
512
|
+
###else
|
|
513
|
+
res=@envir.output(in_type+"{"+txt2+"}",@mode,@escape)
|
|
514
|
+
### p res
|
|
515
|
+
###end
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
when "#F"
|
|
519
|
+
#RMK: protection against extraction -> mainly developped to eval dyndoc code inside dyndoc document!
|
|
520
|
+
txt2=txt2[1..-1].strip if (protect_extract=txt2[0,1]=="!")
|
|
521
|
+
#puts "protect_extract";p protect_extract
|
|
522
|
+
res=(File.exist?(txt2) ? File.read(txt2) : "")
|
|
523
|
+
#p res
|
|
524
|
+
res=Utils.protect_extraction(res) if protect_extract
|
|
525
|
+
#puts "#F:#{txt2}";p res;p out_type
|
|
526
|
+
when ""
|
|
527
|
+
return txt
|
|
528
|
+
end
|
|
529
|
+
#puts "instr:";p txt;p in_type
|
|
530
|
+
#puts "res to convert?";p res;p out_type
|
|
531
|
+
#puts "convert";p convert(res,out_type)
|
|
532
|
+
## Dyndoc.warn "res", [out_type,res]
|
|
533
|
+
return convert(res,out_type)
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
def convert(res,out_type=nil,in_type=nil)
|
|
537
|
+
##puts "convert:";p [res,out_type]
|
|
538
|
+
return res unless out_type
|
|
539
|
+
case out_type
|
|
540
|
+
when ":=",":rb=",":Rb=","#rb=","#Rb="
|
|
541
|
+
#if res.is_a? String
|
|
542
|
+
# res.inspect
|
|
543
|
+
#else res.is_a? Array
|
|
544
|
+
#puts out_type;p res;p res.inspect
|
|
545
|
+
#if res.is_a? Array and res.length==1 and res[0].is_a? String
|
|
546
|
+
# res[0].inspect
|
|
547
|
+
#else
|
|
548
|
+
res.inspect
|
|
549
|
+
#end
|
|
550
|
+
when ":",":rb",":Rb","#rb","#Rb"
|
|
551
|
+
#puts "convert [rb]:";p res
|
|
552
|
+
if res.is_a? Array
|
|
553
|
+
res.join(", ")
|
|
554
|
+
else
|
|
555
|
+
res.to_s
|
|
556
|
+
end
|
|
557
|
+
when ":R=","#R=",":r=","#r="
|
|
558
|
+
if res.is_a? Array
|
|
559
|
+
res2="c("+res.map{|e| "'"+e.to_s+"'"}.join(",")+")"
|
|
560
|
+
res2.gsub!(/\\/,'\\\\\\\\')
|
|
561
|
+
#p res2
|
|
562
|
+
res2
|
|
563
|
+
else
|
|
564
|
+
"'"+res.to_s+"'" #QUESTION???? .gsub(/\\/,'\\\\\\\\')
|
|
565
|
+
end
|
|
566
|
+
when ":R","#R",":r","#r"
|
|
567
|
+
if res.is_a? Array
|
|
568
|
+
res.join(",")
|
|
569
|
+
else
|
|
570
|
+
res.to_s
|
|
571
|
+
end
|
|
572
|
+
when ":jl","#jl"
|
|
573
|
+
if res.is_a? Array
|
|
574
|
+
res.join(",")
|
|
575
|
+
else
|
|
576
|
+
res.to_s
|
|
577
|
+
end
|
|
578
|
+
when "=","@=","#=","##=" ,"none="
|
|
579
|
+
#puts "convert [=]";p res
|
|
580
|
+
if res.is_a? Array
|
|
581
|
+
res.join(",")
|
|
582
|
+
else
|
|
583
|
+
"\""+res.to_s+"\""
|
|
584
|
+
end
|
|
585
|
+
when "","@","#","##","none","#F"
|
|
586
|
+
if res.is_a? Array
|
|
587
|
+
res.join(",")
|
|
588
|
+
else
|
|
589
|
+
res.to_s
|
|
590
|
+
end
|
|
591
|
+
end
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
# def apply(str,mode=nil,to_filter=true,escape=false)
|
|
595
|
+
# ##return str unless to_filter
|
|
596
|
+
# ##RMK: to_filter unused!
|
|
597
|
+
# @mode,@escape=mode,escape
|
|
598
|
+
# #puts "str to apply filter";p str
|
|
599
|
+
# @scan.tokenize(str)
|
|
600
|
+
# ext=@scan.extract
|
|
601
|
+
# #p ext
|
|
602
|
+
# res=@scan.rebuild_after_filter(ext,self)
|
|
603
|
+
# #res=res.split("\n") if @mode==:pre and !res.empty?
|
|
604
|
+
# #puts "res";p res
|
|
605
|
+
# res
|
|
606
|
+
# end
|
|
607
|
+
|
|
608
|
+
def apply(str,mode=nil,to_filter=true,escape=false)
|
|
609
|
+
##return str unless to_filter
|
|
610
|
+
##RMK: to_filter unused!
|
|
611
|
+
@mode,@escape=mode,escape
|
|
612
|
+
res=""
|
|
613
|
+
str.split(Dyndoc::AS_IS).each_with_index do |code,i|
|
|
614
|
+
#puts "code";p code;p i
|
|
615
|
+
if i%2==0
|
|
616
|
+
@scan.tokenize(code)
|
|
617
|
+
ext=@scan.extract
|
|
618
|
+
#p ext
|
|
619
|
+
res2=@scan.rebuild_after_filter(ext,self)
|
|
620
|
+
res << res2
|
|
621
|
+
else
|
|
622
|
+
res << Dyndoc::AS_IS+code+Dyndoc::AS_IS
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
if str.split(Dyndoc::AS_IS).length>1
|
|
626
|
+
Dyndoc.warn "str to apply",str
|
|
627
|
+
Dyndoc.warn "res",res
|
|
628
|
+
end
|
|
629
|
+
res
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
AS_IS='UnfltrdAsIsBlck' #strange unmeaning term to protect in a filter.apply block!
|
|
636
|
+
|
|
637
|
+
end
|