w2tags 0.9.3 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -340
- data/LICENSE +6 -6
- data/MIT-LICENSE +18 -18
- data/Manifest.txt +28 -25
- data/README.rdoc +27 -21
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/w2tags +173 -143
- data/doc/History.rdoc +88 -0
- data/hot/erb.hot +18 -156
- data/hot/erb_base.hot +164 -0
- data/hot/html.hot +30 -31
- data/hot/rails/scaffold.hot +15 -15
- data/hot/vm.hot +8 -8
- data/hot/vm2.hot +34 -34
- data/hot/vm_crud.hot +34 -34
- data/hot/vm_popup.hot +74 -74
- data/lib/tags2w.rb +263 -0
- data/lib/w2tags/block/block_hot.rb +37 -0
- data/lib/w2tags/block/plain_text.rb +57 -57
- data/lib/w2tags/block/remark.rb +37 -37
- data/lib/w2tags/block/sass.rb +68 -66
- data/lib/w2tags/merb_hook.rb +15 -15
- data/lib/w2tags/parser.rb +17 -8
- data/lib/w2tags/rails_hook.rb +15 -15
- data/lib/w2tags/sinatra_hook.rb +74 -50
- data/lib/w2tags.rb +100 -100
- data/plugins/{/w2tags/ → w2tags}/README +2 -2
- data/plugins/{/w2tags//generators//w2scaffold/ → w2tags/generators/w2scaffold}/USAGE +29 -29
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/controller.rb +85 -85
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/functional_test.rb +45 -45
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/helper.rb +2 -2
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/helper_test.rb +4 -4
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/layout.html.erb +17 -17
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/style.css +54 -54
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_edit.html.erb +17 -17
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_edit.html.w2erb +16 -16
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_index.html.erb +23 -23
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_index.html.w2erb +13 -13
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_new.html.erb +16 -16
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_new.html.w2erb +15 -15
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_show.html.erb +9 -9
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_show.html.w2erb +8 -8
- data/plugins/{/w2tags//generators//w2scaffold/ → w2tags/generators/w2scaffold}/w2scaffold_generator.rb +106 -106
- data/plugins/{/w2tags/ → w2tags}/install.rb +0 -0
- data/tasks/ann.rake +81 -81
- data/tasks/bones.rake +21 -21
- data/tasks/gem.rake +126 -126
- data/tasks/git.rake +41 -41
- data/tasks/manifest.rake +49 -49
- data/tasks/notes.rake +28 -28
- data/tasks/post_load.rake +39 -39
- data/tasks/rdoc.rake +51 -51
- data/tasks/rubyforge.rake +57 -57
- data/tasks/setup.rb +268 -268
- data/tasks/spec.rake +55 -55
- data/tasks/svn.rake +48 -48
- data/tasks/test.rake +38 -38
- data/test/vars.hot +30 -30
- data/test/w2tags_basic_usability.rb +187 -187
- data/test/w2tags_enlightning.rb +42 -42
- data/test/w2tags_hot.rb +85 -85
- data/test/w2tags_hot_var.rb +115 -115
- metadata +28 -30
data/hot/vm_popup.hot
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
>>_defineWindow
|
2
|
-
.popup
|
3
|
-
*opt*.jqmNotice
|
4
|
-
%img.jqmClose{alt="close" src="$siteRoot/content/img/icon/close_icon.png"}/
|
5
|
-
%img.jqResize{alt="resize" src="$siteRoot/content/img/icon/resize.png"}/
|
6
|
-
.jqDrag.jqmnTitle
|
7
|
-
%h1 $0
|
8
|
-
#$#_size.jqmnContent
|
9
|
-
|
10
|
-
>>_popup_base
|
11
|
-
%div
|
12
|
-
$#.jqmNotice{style="width:$0px"}
|
13
|
-
%img.jqmClose{alt="close" src="$siteRoot/content/img/icon/close_icon.png"}/
|
14
|
-
%img.jqResize{alt="resize" src="$siteRoot/content/img/icon/resize.gif"}/
|
15
|
-
.jqDrag.jqmnTitle
|
16
|
-
%h1 $2
|
17
|
-
.jqmnContent
|
18
|
-
|
19
|
-
>>_popup_crud
|
20
|
-
-popup_base#dlg_crud $0;$!title2 - CRUD [<span class="popup_t"></span>]
|
21
|
-
%form.form-crud{method="post" action="crud.rails"}
|
22
|
-
<table>
|
23
|
-
-popup_crud_end
|
24
|
-
|
25
|
-
>>_popup_filter
|
26
|
-
-popup_base#dlg_filter $0;Filter $!title2
|
27
|
-
<table>
|
28
|
-
-popup_filter_end
|
29
|
-
|
30
|
-
>>_popup_crud_end
|
31
|
-
<</
|
32
|
-
</table>
|
33
|
-
<input class="btncrud save" type="submit" name="submit" value="SAVE"/>
|
34
|
-
<input class="h btncrud update" type="submit" name="submit" value="UPDATE"/>
|
35
|
-
<input class="btncrud delete" type="submit" name="submit" value="DELETE"/>
|
36
|
-
<input class="btncrud jqmClose" type="button" value="CLOSE"/>
|
37
|
-
|
38
|
-
>>_popup_filter_end
|
39
|
-
<</
|
40
|
-
<tr>
|
41
|
-
<td colspan=2 align=center>
|
42
|
-
<input class="btncrud filter" type="submit" reset="false" value="FILTER"/>
|
43
|
-
<input class="btncrud jqmClose" type="button" value="CLOSE"/>
|
44
|
-
</td>
|
45
|
-
</tr>
|
46
|
-
</table>
|
47
|
-
|
48
|
-
>>_input_crud
|
49
|
-
:
|
50
|
-
%input#:gsub('.','_')$0$1{name="$0"}/
|
51
|
-
|
52
|
-
>>_tr_crud
|
53
|
-
%tr
|
54
|
-
%td $0
|
55
|
-
%td*opt* :$1
|
56
|
-
|
57
|
-
>>_tr_crud2
|
58
|
-
%tr
|
59
|
-
%td $0
|
60
|
-
%td*opt*
|
61
|
-
-input_crud $*
|
62
|
-
|
63
|
-
>>_tr_crud0
|
64
|
-
%tr
|
65
|
-
%td $0
|
66
|
-
%td*opt*
|
67
|
-
:
|
68
|
-
|
69
|
-
>>_tr_filter
|
70
|
-
%tr
|
71
|
-
%td $0
|
72
|
-
%td
|
73
|
-
:
|
74
|
-
%input*opt*.fill/
|
1
|
+
>>_defineWindow
|
2
|
+
.popup
|
3
|
+
*opt*.jqmNotice
|
4
|
+
%img.jqmClose{alt="close" src="$siteRoot/content/img/icon/close_icon.png"}/
|
5
|
+
%img.jqResize{alt="resize" src="$siteRoot/content/img/icon/resize.png"}/
|
6
|
+
.jqDrag.jqmnTitle
|
7
|
+
%h1 $0
|
8
|
+
#$#_size.jqmnContent
|
9
|
+
|
10
|
+
>>_popup_base
|
11
|
+
%div
|
12
|
+
$#.jqmNotice{style="width:$0px"}
|
13
|
+
%img.jqmClose{alt="close" src="$siteRoot/content/img/icon/close_icon.png"}/
|
14
|
+
%img.jqResize{alt="resize" src="$siteRoot/content/img/icon/resize.gif"}/
|
15
|
+
.jqDrag.jqmnTitle
|
16
|
+
%h1 $2
|
17
|
+
.jqmnContent
|
18
|
+
|
19
|
+
>>_popup_crud
|
20
|
+
-popup_base#dlg_crud $0;$!title2 - CRUD [<span class="popup_t"></span>]
|
21
|
+
%form.form-crud{method="post" action="crud.rails"}
|
22
|
+
<table>
|
23
|
+
-popup_crud_end
|
24
|
+
|
25
|
+
>>_popup_filter
|
26
|
+
-popup_base#dlg_filter $0;Filter $!title2
|
27
|
+
<table>
|
28
|
+
-popup_filter_end
|
29
|
+
|
30
|
+
>>_popup_crud_end
|
31
|
+
<</
|
32
|
+
</table>
|
33
|
+
<input class="btncrud save" type="submit" name="submit" value="SAVE"/>
|
34
|
+
<input class="h btncrud update" type="submit" name="submit" value="UPDATE"/>
|
35
|
+
<input class="btncrud delete" type="submit" name="submit" value="DELETE"/>
|
36
|
+
<input class="btncrud jqmClose" type="button" value="CLOSE"/>
|
37
|
+
|
38
|
+
>>_popup_filter_end
|
39
|
+
<</
|
40
|
+
<tr>
|
41
|
+
<td colspan=2 align=center>
|
42
|
+
<input class="btncrud filter" type="submit" reset="false" value="FILTER"/>
|
43
|
+
<input class="btncrud jqmClose" type="button" value="CLOSE"/>
|
44
|
+
</td>
|
45
|
+
</tr>
|
46
|
+
</table>
|
47
|
+
|
48
|
+
>>_input_crud
|
49
|
+
:
|
50
|
+
%input#:gsub('.','_')$0$1{name="$0"}/
|
51
|
+
|
52
|
+
>>_tr_crud
|
53
|
+
%tr
|
54
|
+
%td $0
|
55
|
+
%td*opt* :$1
|
56
|
+
|
57
|
+
>>_tr_crud2
|
58
|
+
%tr
|
59
|
+
%td $0
|
60
|
+
%td*opt*
|
61
|
+
-input_crud $*
|
62
|
+
|
63
|
+
>>_tr_crud0
|
64
|
+
%tr
|
65
|
+
%td $0
|
66
|
+
%td*opt*
|
67
|
+
:
|
68
|
+
|
69
|
+
>>_tr_filter
|
70
|
+
%tr
|
71
|
+
%td $0
|
72
|
+
%td
|
73
|
+
:
|
74
|
+
%input*opt*.fill/
|
data/lib/tags2w.rb
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
require 'hpricot'
|
2
|
+
|
3
|
+
class Tags2w
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@cod_if = false
|
7
|
+
@doc_out= []
|
8
|
+
@level = 0
|
9
|
+
@line = ''
|
10
|
+
@tags = %w[h1]
|
11
|
+
end
|
12
|
+
|
13
|
+
def start(el)
|
14
|
+
initialize
|
15
|
+
sub_element(el)
|
16
|
+
end
|
17
|
+
|
18
|
+
def result
|
19
|
+
@doc_out
|
20
|
+
end
|
21
|
+
|
22
|
+
def element(el)
|
23
|
+
if el.class==Hpricot::Text
|
24
|
+
tag= el.name
|
25
|
+
elsif el.class==Hpricot::Comment
|
26
|
+
tag= "<!--#{el.name}-->"
|
27
|
+
else
|
28
|
+
#p el.html
|
29
|
+
at = el.respond_to?(:attributes) ? el.attributes : {}
|
30
|
+
tag= "%#{el.name}"
|
31
|
+
if at['name']
|
32
|
+
tag<<":#{at['name']}"
|
33
|
+
at.delete 'name'
|
34
|
+
end
|
35
|
+
if at['id']
|
36
|
+
tag<<"##{at['id']}"
|
37
|
+
at.delete 'id'
|
38
|
+
end
|
39
|
+
if at['class']
|
40
|
+
tag<<".#{at['class'].split(' ').join('.')}"
|
41
|
+
at.delete 'class'
|
42
|
+
end
|
43
|
+
if at.length>0
|
44
|
+
ex= at.collect{|k,v|[k,'="',v,'"'].join}.join(' ')
|
45
|
+
tag<<"{#{ex}}"
|
46
|
+
end
|
47
|
+
if /\%div([#.])/ =~ tag
|
48
|
+
tag.gsub!(/\%div([#.])/,$1)
|
49
|
+
else
|
50
|
+
tag.gsub!(/\%input\:/,':')
|
51
|
+
end
|
52
|
+
if /\%cmd\./ =~ tag
|
53
|
+
#puts tag
|
54
|
+
tag.gsub!(/\%cmd\.if\{(.*?)\}/ , "-if #{$1}") if /\%cmd\.if\{att="(.*?)"\}/ =~ tag
|
55
|
+
tag.gsub!(/\%cmd\.for\{(.*?)\}/ , "-for #{$1}") if /\%cmd\.for\{att="(.*?)"\}/ =~ tag
|
56
|
+
tag.gsub!(/\%cmd\.unless\{(.*?)\}/,"-unless #{$1}") if /\%cmd\.unless\{att="(.*?)"\}/=~ tag
|
57
|
+
tag.gsub!(/\%cmd\.elsif\{(.*?)\}/ , "-elsif #{$1}") if /\%cmd\.elsif\{att="(.*?)"\}/ =~ tag
|
58
|
+
tag.gsub!(/\%cmd\.else\{(.*?)\}/ , "-else #{$1}") if /\%cmd\.else\{att="(.*?)"\}/ =~ tag
|
59
|
+
tag.gsub!(/\%cmd\.each\{(.*?)\}/ , "-each #{$1}") if /\%cmd\.each\{att="(.*?)"\}/ =~ tag
|
60
|
+
tag.gsub!(/\%cmd\.each2\{(.*?)\}/ , "-each2 #{$1}") if /\%cmd\.each2\{att="(.*?)"\}/ =~ tag
|
61
|
+
tag.gsub!(/\%cmd\.form_tag\{(.*?)\}/,"-form_tag #{$1}") if /\%cmd\.form_tag\{att="(.*?)"\}/=~ tag
|
62
|
+
tag.gsub!(/\%cmd\.form_for\{(.*?)\}/,"-form_for #{$1}") if /\%cmd\.form_for\{att="(.*?)"\}/=~ tag
|
63
|
+
else
|
64
|
+
tag.gsub!(/\%\<\?xml/ , "<?xml") if /^\%\<\?xml/ =~ tag
|
65
|
+
tag.gsub!(/\%\<\!DOCTYPE/ , "<!DOCTYPE") if /^\%\<\!DOCTYPE/ =~ tag
|
66
|
+
end
|
67
|
+
end
|
68
|
+
tag
|
69
|
+
end
|
70
|
+
|
71
|
+
def equal(line)
|
72
|
+
rtn = []
|
73
|
+
line.split("\n").each do |ln|
|
74
|
+
if /\<%=(.*)[-]?%\>/=~ ln
|
75
|
+
rtn<< ('= '<< $1.lstrip.gsub(/\-$/,'') )
|
76
|
+
else
|
77
|
+
rtn<< (' ' << ln.rstrip)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
rtn.join("\n")
|
81
|
+
end
|
82
|
+
|
83
|
+
def ruby_equal(el)
|
84
|
+
rtn = equal(element(el).strip).gsub(/ *\%w2code_equ/,'=')
|
85
|
+
ch= el.respond_to?(:children) ? el.children : nil
|
86
|
+
if ch && ch.length==1
|
87
|
+
rtn<< ruby_equal(el.children[0])
|
88
|
+
end
|
89
|
+
rtn
|
90
|
+
end
|
91
|
+
|
92
|
+
def in_block(blk)
|
93
|
+
spc1= ' '*(@level)
|
94
|
+
spc2= ' '*(@level+1)
|
95
|
+
[spc1,blk.gsub(/\n +/,"\n#{spc2}")].join
|
96
|
+
end
|
97
|
+
|
98
|
+
def in_block2(blk)
|
99
|
+
les= 999
|
100
|
+
spc= ' '*(@level+1)
|
101
|
+
#blk= [' ',blk].join
|
102
|
+
lns= blk.split("\n")
|
103
|
+
lns.each do |l|
|
104
|
+
x=(/ */=~l)
|
105
|
+
les=x if x<les
|
106
|
+
end
|
107
|
+
lns.collect {|l|[spc,l[les,999]].join}.join("\n").sub(/^ /,'')
|
108
|
+
end
|
109
|
+
|
110
|
+
def sub_element(parent)
|
111
|
+
if parent.children
|
112
|
+
parent.children.each do |el|
|
113
|
+
@line= element(el).strip
|
114
|
+
if @line!=''
|
115
|
+
if el.class==Hpricot::Comment
|
116
|
+
@doc_out << [' '*(@level),@line].join
|
117
|
+
elsif el.class==Hpricot::Text
|
118
|
+
@doc_out << [' '*(@level),@line].join
|
119
|
+
else
|
120
|
+
if el.name=='script'
|
121
|
+
@doc_out << in_block2(@line << el.html)
|
122
|
+
elsif el.name=='w2comment'
|
123
|
+
@doc_out << in_block2("%comment"<< el.html)
|
124
|
+
elsif el.name=='w2code_equ'
|
125
|
+
@doc_out << in_block2("="<< el.html)
|
126
|
+
else
|
127
|
+
ch= el.respond_to?(:children) ? el.children : nil
|
128
|
+
if @line[0,1]!='-' && ch && ch.length==1
|
129
|
+
inline= ruby_equal(el.children[0])
|
130
|
+
inline= " (#{inline.lstrip}%)" if /\%\w/ =~ inline
|
131
|
+
@doc_out << [' '*@level,@line,inline].join
|
132
|
+
else
|
133
|
+
if /\%cmd/ !~ @line
|
134
|
+
rtn= [' '*@level,@line].join
|
135
|
+
rtn.gsub!('<w2code_equ>','<%=')
|
136
|
+
rtn.gsub!('</w2code_equ>','%>')
|
137
|
+
@doc_out << rtn
|
138
|
+
if ch
|
139
|
+
@level+=1
|
140
|
+
sub_element(el)
|
141
|
+
@level-=1
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
def line_code
|
154
|
+
@doc_med= []
|
155
|
+
@doc_out.join("\n").split("\n").each_with_index do |ln,i|
|
156
|
+
doc= ''
|
157
|
+
if /[^"] *\<%(=.*)[-]?%\>/=~ ln
|
158
|
+
ln.gsub!(/[^"] *\<%=.*[-]?%\>/,$1.lstrip.gsub(/\-$/,''))
|
159
|
+
@doc_med<< ln
|
160
|
+
elsif /[^"] *\<%[-]?(.*)[-]?%\>/ =~ ln
|
161
|
+
code= $1.lstrip.gsub(/\-$/,'')
|
162
|
+
part= code.split(/ +/)[0]
|
163
|
+
if %w[if elsif else].index(part)
|
164
|
+
@cod_if = true
|
165
|
+
code= "-#{code}"
|
166
|
+
else
|
167
|
+
code= "- #{code}"
|
168
|
+
end
|
169
|
+
if @cod_if && (%w[end].index(part))
|
170
|
+
@cod_if= false
|
171
|
+
else
|
172
|
+
ln.gsub!(/\<%[-]?.*[-]?%\>/,code)
|
173
|
+
@doc_med<< ln
|
174
|
+
end
|
175
|
+
else
|
176
|
+
@doc_med<< ln
|
177
|
+
end
|
178
|
+
end
|
179
|
+
@doc_out= @doc_med
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
class MakeTag
|
186
|
+
|
187
|
+
def make_it(lines)
|
188
|
+
@lvl_dp= 0
|
189
|
+
@blk_ar= Array.new(20,['']) #level, space
|
190
|
+
lines.each_with_index do |l,i|
|
191
|
+
dbg=''
|
192
|
+
if /( *)\<%[-]? *(\w+)[(]?(.*?)[)]? *do *\|(.*?)\|/ =~ l
|
193
|
+
@lvl_dp += 1
|
194
|
+
if $3=='.each'
|
195
|
+
blk= ["<cmd class=\"#{$3[1,99]}\" att=\"#{$2};#{$4}\">","<form_for>"]
|
196
|
+
else
|
197
|
+
blk= ["<cmd class=\"#{$2}\" att=\"#{$3};#{$4}\">","<form_for>"]
|
198
|
+
end
|
199
|
+
dbg<< "#{$1}#{blk[0]}"
|
200
|
+
@blk_ar[@lvl_dp]= blk
|
201
|
+
elsif /( *)\<%[-]? *(\w+)[(]?(.*?)[)]? *do *$/ =~ l
|
202
|
+
@lvl_dp += 1
|
203
|
+
blk= ["<cmd class=\"#{$2}\" att=\"#{$3}\">","<form_tag>"]
|
204
|
+
dbg<< "#{$1}#{blk[0]}"
|
205
|
+
@blk_ar[@lvl_dp]= blk
|
206
|
+
elsif /( *)\<%[-]? *(.*? ) *do *\|(.*?)\|/ =~ l
|
207
|
+
spc= $1
|
208
|
+
cmd= $2
|
209
|
+
att= $3
|
210
|
+
#cmd=$2.split('.')[0]
|
211
|
+
att= $3.lstrip.gsub(/\-$/,'')
|
212
|
+
if cmd.gsub!(/.each /,'')
|
213
|
+
blk= ["<cmd class=\"each\" att=\"#{cmd};#{att}\">" ,'<each>']
|
214
|
+
elsif cmd.gsub!(/.each_with_index /,'')
|
215
|
+
blk= ["<cmd class=\"each2\" att=\"#{cmd};#{att}\">",'<each2>']
|
216
|
+
else
|
217
|
+
blk= ["<cmd class=\"#{cmd}\" att=\"#{att}\">","<#{cmd}>"]
|
218
|
+
end
|
219
|
+
@lvl_dp += 1
|
220
|
+
@blk_ar[@lvl_dp]= blk
|
221
|
+
dbg<< "#{spc}#{blk[0]}"
|
222
|
+
elsif /( *)\<%[-]? *([\w_]+) *(.*?)[-]?%>/ =~ l
|
223
|
+
spc= $1
|
224
|
+
cmd= $2
|
225
|
+
att= $3.lstrip.gsub(/\-$/,'')
|
226
|
+
if %w[unless if for].index(cmd)
|
227
|
+
@lvl_dp += 1
|
228
|
+
blk= ["<cmd class=\"#{cmd}\" att=\"#{att}\">","<#{cmd}>"]
|
229
|
+
dbg<< "#{spc}#{blk[0]}"
|
230
|
+
@blk_ar[@lvl_dp]= blk
|
231
|
+
elsif %w[elsif else].index(cmd)
|
232
|
+
blk= ["</cmd><cmd class=\"#{cmd}\" att=\"#{att}\">","<#{cmd}>"]
|
233
|
+
dbg<< "#{spc}#{blk[0]}"
|
234
|
+
@blk_ar[@lvl_dp]= blk
|
235
|
+
elsif %w[end].index(cmd)
|
236
|
+
blk= ["</cmd>"]
|
237
|
+
dbg<< "#{spc}#{blk[0]}"
|
238
|
+
@lvl_dp -= 1
|
239
|
+
end
|
240
|
+
elsif /( *)\<%=(.*?)%>/ =~ l
|
241
|
+
while /( *)\<%=(.*?)%>/ =~ l do
|
242
|
+
l= l.sub(/( *)\<%=(.*?)%>/,"#{spc}<w2code_equ>#{$2}</w2code_equ>")
|
243
|
+
end
|
244
|
+
dbg<< l
|
245
|
+
elsif /( *)\<\!\-\-(.*)\-\-\>/ =~ l
|
246
|
+
dbg<< "#{spc}<w2comment>#{$2}</w2comment>"
|
247
|
+
elsif /( *)\<\!\-\-(.*)/ =~ l
|
248
|
+
@lvl_dp += 1
|
249
|
+
blk= ["<w2comment>#{$2}",'<comment>']
|
250
|
+
@blk_ar[@lvl_dp]= blk
|
251
|
+
dbg<< "#{spc}#{blk[0]}"
|
252
|
+
elsif /(.*)\-\-\>/ =~ l
|
253
|
+
blk= ["#{$1}</w2comment>"]
|
254
|
+
dbg<< "#{spc}#{blk[0]}"
|
255
|
+
@lvl_dp -= 1
|
256
|
+
end
|
257
|
+
if dbg!=''
|
258
|
+
#puts dbg
|
259
|
+
lines[i]= dbg
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module W2Tags
|
2
|
+
module Block
|
3
|
+
module BlockHot
|
4
|
+
def bhot_skip_initialize
|
5
|
+
@key_hot= '' #key for hot
|
6
|
+
@doc_hot= [] #bhot buffer
|
7
|
+
@bht = 99 #hot indentation block
|
8
|
+
end
|
9
|
+
|
10
|
+
def bhot_skip
|
11
|
+
@rgx = nil
|
12
|
+
if(/(^[\t ]*)(!H!) *(\w+)\n/ =~ @row;@rgx = $~)
|
13
|
+
@key_hot= $3.strip
|
14
|
+
@doc_hot= [] #bhot buffer
|
15
|
+
@bht = @spc.size
|
16
|
+
elsif @bht!= 99
|
17
|
+
if @spc.size<= @bht
|
18
|
+
les= 999
|
19
|
+
@doc_hot.each do |l|
|
20
|
+
if l.strip!=''
|
21
|
+
x=(/[^ ]/=~l)
|
22
|
+
les=x if x<les
|
23
|
+
end
|
24
|
+
end
|
25
|
+
ref =@doc_hot.collect{|l|l[les,999]}.join
|
26
|
+
@tg_hot[@key_hot]= [proc {|this|ref}, nil]
|
27
|
+
@bht = 99
|
28
|
+
elsif @row.strip!=''
|
29
|
+
@doc_hot<< @row
|
30
|
+
end
|
31
|
+
end
|
32
|
+
@row = '' if @bht!=99
|
33
|
+
@bht!=99
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,57 +1,57 @@
|
|
1
|
-
module W2Tags
|
2
|
-
module Block
|
3
|
-
module PlainText
|
4
|
-
#when command is "-!", it means that inside these
|
5
|
-
#indentation will not be parsed.
|
6
|
-
# Example:
|
7
|
-
# %head
|
8
|
-
# %script
|
9
|
-
# -!
|
10
|
-
# $(function(){
|
11
|
-
# alert('Hello World');
|
12
|
-
# });
|
13
|
-
def plain_text_skip_initialize()
|
14
|
-
@plt_opt= '' #plaintext option
|
15
|
-
@doc_plt= [] #plaintext buffer
|
16
|
-
@plt = 99 #plaintext indentation
|
17
|
-
end
|
18
|
-
|
19
|
-
def plain_text_skip
|
20
|
-
@rgx = nil
|
21
|
-
@plt_opt = ''
|
22
|
-
if(/(^[\t ]*)(-!+[ ]?)([^\n]*)\n/ =~ @row;@rgx = $~)
|
23
|
-
@row = ''
|
24
|
-
@plt = @spc.size
|
25
|
-
@plt_opt = @rgx[2]
|
26
|
-
@doc_plt = []
|
27
|
-
if @rgx[3].strip != ""
|
28
|
-
if @plt_opt[1,2]=='!!'
|
29
|
-
@doc_plt << " #{@rgx[3].strip}\n"
|
30
|
-
else
|
31
|
-
@doc_plt << "#{@spc} #{@rgx[3].strip}\n"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
elsif @plt != 99
|
35
|
-
if @spc.size<= @plt
|
36
|
-
@doc_out = @doc_out + @doc_plt
|
37
|
-
@plt = 99
|
38
|
-
else
|
39
|
-
plain_text_parser
|
40
|
-
end
|
41
|
-
end
|
42
|
-
@plt!=99
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def plain_text_parser
|
48
|
-
if @plt_opt[1,2]=='!!'
|
49
|
-
@doc_plt << @row[@plt,999].rstrip<<"\n"
|
50
|
-
else
|
51
|
-
@doc_plt << @row.rstrip<<"\n"
|
52
|
-
end
|
53
|
-
@row = ''
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
module W2Tags
|
2
|
+
module Block
|
3
|
+
module PlainText
|
4
|
+
#when command is "-!", it means that inside these
|
5
|
+
#indentation will not be parsed.
|
6
|
+
# Example:
|
7
|
+
# %head
|
8
|
+
# %script
|
9
|
+
# -!
|
10
|
+
# $(function(){
|
11
|
+
# alert('Hello World');
|
12
|
+
# });
|
13
|
+
def plain_text_skip_initialize()
|
14
|
+
@plt_opt= '' #plaintext option
|
15
|
+
@doc_plt= [] #plaintext buffer
|
16
|
+
@plt = 99 #plaintext indentation
|
17
|
+
end
|
18
|
+
|
19
|
+
def plain_text_skip
|
20
|
+
@rgx = nil
|
21
|
+
@plt_opt = ''
|
22
|
+
if(/(^[\t ]*)(-!+[ ]?)([^\n]*)\n/ =~ @row;@rgx = $~)
|
23
|
+
@row = ''
|
24
|
+
@plt = @spc.size
|
25
|
+
@plt_opt = @rgx[2]
|
26
|
+
@doc_plt = []
|
27
|
+
if @rgx[3].strip != ""
|
28
|
+
if @plt_opt[1,2]=='!!'
|
29
|
+
@doc_plt << " #{@rgx[3].strip}\n"
|
30
|
+
else
|
31
|
+
@doc_plt << "#{@spc} #{@rgx[3].strip}\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
elsif @plt != 99
|
35
|
+
if @spc.size<= @plt
|
36
|
+
@doc_out = @doc_out + @doc_plt
|
37
|
+
@plt = 99
|
38
|
+
else
|
39
|
+
plain_text_parser
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@plt!=99
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def plain_text_parser
|
48
|
+
if @plt_opt[1,2]=='!!'
|
49
|
+
@doc_plt << @row[@plt,999].rstrip<<"\n"
|
50
|
+
else
|
51
|
+
@doc_plt << @row.rstrip<<"\n"
|
52
|
+
end
|
53
|
+
@row = ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/w2tags/block/remark.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
module W2Tags
|
2
|
-
module Block
|
3
|
-
module Remark
|
4
|
-
#when command is "-#", it means that inside these
|
5
|
-
#indentation will not include on the result or it
|
6
|
-
#become some comment.
|
7
|
-
# Example:
|
8
|
-
# -#
|
9
|
-
# THIS COMMENT
|
10
|
-
# WILL NOT SHOW ON RESULT
|
11
|
-
def remark_skip_initialize
|
12
|
-
@rmk = 99 #remark indentation
|
13
|
-
end
|
14
|
-
|
15
|
-
def empty_skip
|
16
|
-
@row.strip == ''
|
17
|
-
end
|
18
|
-
|
19
|
-
def line_skip
|
20
|
-
if /(^[\t ]*)(\\)([^\n]*\n)/ =~ @row #escape for plain text "\- "
|
21
|
-
@row = $1+$3
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def remark_skip
|
26
|
-
if(/(^[\t ]*)(-#)([^\n]*)\n/ =~ @row;@rgx = $~)
|
27
|
-
@rmk = @spc.size #@plt = 99
|
28
|
-
elsif @rmk !=99
|
29
|
-
@rmk = 99 if @spc.size <= @rmk
|
30
|
-
#p "remrk> #{@rgx[3].strip}" if @dbg[:parse]
|
31
|
-
end
|
32
|
-
@row = '' if @rmk!=99
|
33
|
-
@rmk!=99
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
module W2Tags
|
2
|
+
module Block
|
3
|
+
module Remark
|
4
|
+
#when command is "-#", it means that inside these
|
5
|
+
#indentation will not include on the result or it
|
6
|
+
#become some comment.
|
7
|
+
# Example:
|
8
|
+
# -#
|
9
|
+
# THIS COMMENT
|
10
|
+
# WILL NOT SHOW ON RESULT
|
11
|
+
def remark_skip_initialize
|
12
|
+
@rmk = 99 #remark indentation
|
13
|
+
end
|
14
|
+
|
15
|
+
def empty_skip
|
16
|
+
@row.strip == ''
|
17
|
+
end
|
18
|
+
|
19
|
+
def line_skip
|
20
|
+
if /(^[\t ]*)(\\)([^\n]*\n)/ =~ @row #escape for plain text "\- "
|
21
|
+
@row = $1+$3
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def remark_skip
|
26
|
+
if(/(^[\t ]*)(-#)([^\n]*)\n/ =~ @row;@rgx = $~)
|
27
|
+
@rmk = @spc.size #@plt = 99
|
28
|
+
elsif @rmk !=99
|
29
|
+
@rmk = 99 if @spc.size <= @rmk
|
30
|
+
#p "remrk> #{@rgx[3].strip}" if @dbg[:parse]
|
31
|
+
end
|
32
|
+
@row = '' if @rmk!=99
|
33
|
+
@rmk!=99
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|