w2tags 0.9.65 → 0.9.67
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.
- data/README.rdoc +9 -8
- data/VERSION +1 -1
- data/bin/w2tags +4 -2
- data/doc/History.rdoc +80 -0
- data/hot/erb_base.hot +1 -1
- data/hot/html.hot +6 -0
- data/lib/w2tags/parser.rb +30 -12
- data/lib/w2tags/try/views/index.erb +1 -99
- data/lib/w2tags/try/views/layout.erb +1 -0
- data/tasks/setup.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
= W2TAGS
|
2
2
|
=== Run on MRI Ruby : 1.8.6 / 1.9.x
|
3
3
|
|
4
|
-
|
4
|
+
gem install w2tags
|
5
5
|
|
6
|
-
|
7
|
-
ARGV
|
6
|
+
w2tags -irb
|
7
|
+
ARGV : -irb
|
8
8
|
|
9
9
|
Your W2Tags instance object stored in WH...
|
10
10
|
Ex: puts WH.parse_line("#content\n %span Hello")
|
@@ -13,15 +13,15 @@
|
|
13
13
|
irb(main):001:0> wh <<END
|
14
14
|
irb(main):002:0" #wow
|
15
15
|
irb(main):003:0" #kereen
|
16
|
-
irb(main):004:0" . Hello World
|
16
|
+
irb(main):004:0" .greeting Hello World
|
17
17
|
irb(main):005:0" END
|
18
|
-
=>/usr/lib/ruby/gems/1.8/gems/
|
18
|
+
=>/usr/lib/ruby/gems/1.8/gems/w2tags-0.9.67/hot/erb.hot
|
19
19
|
<div id="wow">
|
20
20
|
<div id="kereen">
|
21
|
-
<div>Hello World</div>
|
21
|
+
<div class="greeting">Hello World</div>
|
22
22
|
</div>
|
23
23
|
</div>
|
24
|
-
=>
|
24
|
+
=> ["<div id="wow">\n", " <div id="kereen">\n", " <div class="greeting">Hello World</div>\n", " </div>\n", "</div>\n"]
|
25
25
|
irb(main):006:0>
|
26
26
|
|
27
27
|
== DESCRIPTION:
|
@@ -43,8 +43,9 @@ define uniq variable "@var=", Key-Variable
|
|
43
43
|
"$:","*:" for attribute NAME,
|
44
44
|
"$#","*#" for attribute ID,
|
45
45
|
"$.","*." for attribute CLASS,
|
46
|
+
"$$" for all Key-Variable,
|
46
47
|
"$@","*@" for custome attribute,
|
47
|
-
"
|
48
|
+
"$=" for ruby code ("=" or "==" last Key-Variable).
|
48
49
|
|
49
50
|
This Constanta will be ready every time it parse the W2TAGS HOT (% / -).
|
50
51
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.67
|
data/bin/w2tags
CHANGED
@@ -57,7 +57,7 @@ end
|
|
57
57
|
arg = ARGV
|
58
58
|
if arg.size>0
|
59
59
|
arg = ['w2erb'] + arg if arg.size==1 && arg[0]=='-a'
|
60
|
-
puts 'ARGV
|
60
|
+
puts 'ARGV : '+arg.join(" ")
|
61
61
|
puts arg[1]
|
62
62
|
|
63
63
|
WH = W2Tags::Parser.new
|
@@ -80,7 +80,9 @@ if arg.size>0
|
|
80
80
|
|
81
81
|
class Object
|
82
82
|
def wh(str)
|
83
|
-
|
83
|
+
rtn = WH.parse_line(str)
|
84
|
+
puts rtn
|
85
|
+
rtn
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
data/doc/History.rdoc
CHANGED
@@ -2,6 +2,86 @@
|
|
2
2
|
|
3
3
|
Below is a complete list of changes for each revision of W2TAGS.
|
4
4
|
|
5
|
+
== 0.9.67
|
6
|
+
|
7
|
+
=== Parser
|
8
|
+
* New Var-Constanta in HOT - "$="
|
9
|
+
* Splitter ':' in hot params
|
10
|
+
|
11
|
+
==== New Var-Constanta in HOT - "$=", this var fix the need of reconstruct Key-attributes to the tag
|
12
|
+
with costume attribute
|
13
|
+
|
14
|
+
-# Example
|
15
|
+
|
16
|
+
>>_menu
|
17
|
+
%div$${editor="eclipse" *@}$= $0
|
18
|
+
|
19
|
+
>>>W2TAGS>>>
|
20
|
+
-menu.dor{style="font:bold;"}== 0
|
21
|
+
|
22
|
+
<div class="dor" editor="eclipse" style="font:bold;"><%= "0" %></div>
|
23
|
+
|
24
|
+
==== Parameter in hot support splitter ':' to enhance the parameter manipulation
|
25
|
+
|
26
|
+
-# Example:
|
27
|
+
|
28
|
+
>>_a
|
29
|
+
%a$${href="$0.split(':')[1].to_s.strip~" *@}$= $0.split(':')[0].to_s.strip~
|
30
|
+
|
31
|
+
%a$${href="$0:1" *@}$= $0:0
|
32
|
+
|
33
|
+
Two command above will produce the same result
|
34
|
+
|
35
|
+
-a.dodol.garut{style="blue"}= \
|
36
|
+
Wow : # ;\
|
37
|
+
Home : / ;\
|
38
|
+
Next : /next
|
39
|
+
|
40
|
+
-a.dodol.garut{style="background:blue;"}= \
|
41
|
+
Wow : # ;\ Home : / ;\
|
42
|
+
Next : /next
|
43
|
+
|
44
|
+
<a class="dodol garut" href="#" style="background:blue;"><%= Wow %></a>
|
45
|
+
<a class="dodol garut" href="/" style="background:blue;"><%= Home %></a>
|
46
|
+
<a class="dodol garut" href="/next" style="background:blue;"><%= Next %></a>
|
47
|
+
|
48
|
+
== 0.9.66
|
49
|
+
|
50
|
+
=== Parser
|
51
|
+
* Auto closing tag in HOT now properly indented
|
52
|
+
|
53
|
+
==== Auto closing tag in HOT now properly indented
|
54
|
+
this example show how we redefine the tag %script to automatically
|
55
|
+
generate <script *all**@type="text/javascript" charset="utf-8">, with
|
56
|
+
xhtml comment and line below this tag must not be parse
|
57
|
+
|
58
|
+
-# Example:
|
59
|
+
>>script
|
60
|
+
<script *all**@type="text/javascript" charset="utf-8">
|
61
|
+
%script_end
|
62
|
+
-!
|
63
|
+
|
64
|
+
>>script_end
|
65
|
+
<</
|
66
|
+
</script>
|
67
|
+
|
68
|
+
>>_script_tag
|
69
|
+
%script
|
70
|
+
//<![CDATA[
|
71
|
+
==$0;
|
72
|
+
//]]>
|
73
|
+
|
74
|
+
>>>W2TAGS>>>
|
75
|
+
-script_tag var instant= '#{@line}'
|
76
|
+
|
77
|
+
Result of w2tags command above will be xhtml tag below with proper indentation
|
78
|
+
|
79
|
+
<script type="text/javascript" charset="utf-8">
|
80
|
+
//<![CDATA[
|
81
|
+
<%= "var instant= '#{@line}'" %>;
|
82
|
+
//]]>
|
83
|
+
</script>
|
84
|
+
|
5
85
|
== 0.9.65
|
6
86
|
|
7
87
|
=== Parser
|
data/hot/erb_base.hot
CHANGED
data/hot/html.hot
CHANGED
data/lib/w2tags/parser.rb
CHANGED
@@ -204,9 +204,11 @@ module W2Tags
|
|
204
204
|
@row.gsub!(/([\n\t ]*$)/,'')
|
205
205
|
@row << "#{@ln_end.strip}\n"
|
206
206
|
end
|
207
|
-
if @row.strip!=""
|
207
|
+
if @row.strip!="" # responsible for generating good output
|
208
208
|
p "#####> #{@row}" if @dbg[:parse]
|
209
|
-
@doc_out << @row.rstrip+"\n"
|
209
|
+
@doc_out << (@row.rstrip + "\n")
|
210
|
+
#@doc_out << @row.rstrip # not working for
|
211
|
+
#@doc_out << "\n" # shortcut if elsif else
|
210
212
|
end
|
211
213
|
@row
|
212
214
|
end
|
@@ -276,12 +278,12 @@ module W2Tags
|
|
276
278
|
# try to shift empty line create document and add current
|
277
279
|
# row to source. but it means re parsing current row.
|
278
280
|
def swap_last_empt_src_with_end_tg(end_tg)
|
279
|
-
|
280
|
-
|
281
|
-
last << @doc_out.pop
|
281
|
+
while @doc_out[-1] && @doc_out[-1].strip == ''
|
282
|
+
@doc_out.pop
|
282
283
|
end
|
284
|
+
@doc_out<< "\n" if @doc_out[-1] && @doc_out[-1][-1,1] != "\n" # responsible for generating good output
|
283
285
|
end_tg.shift if end_tg[0].strip==''
|
284
|
-
@doc_src = end_tg + @doc_src
|
286
|
+
@doc_src = end_tg + @doc_src #; p @doc_src; p @doc_out
|
285
287
|
#p "Swp..: #{@doc_src[-1]}" if @dbg[:parse]
|
286
288
|
end
|
287
289
|
|
@@ -450,6 +452,7 @@ module W2Tags
|
|
450
452
|
@new += "\n"+@spc
|
451
453
|
end
|
452
454
|
end
|
455
|
+
p "Rept1: #{@new}" if @dbg[:parse]
|
453
456
|
elsif new_alls==[] && new_prms.size==1 && prms.size>1
|
454
457
|
tmp = ""
|
455
458
|
rpt = @rgx.to_s.gsub(@rgx[3]+"\n","")
|
@@ -474,15 +477,25 @@ module W2Tags
|
|
474
477
|
tmp<< "\n#{@spc}" if i+1<prms.size
|
475
478
|
end
|
476
479
|
end
|
480
|
+
p "Rept2: #{tmp}" if @dbg[:parse]
|
477
481
|
@new = tmp
|
478
482
|
else
|
479
483
|
i = new_prms.size - 1
|
480
484
|
new_prms.sort.reverse.each do |x|
|
485
|
+
while Regexp.new('\\'+x+':(\d+)') =~ "\n#{@new}" do
|
486
|
+
idx = $1
|
487
|
+
src = $~.to_s
|
488
|
+
rpl = idx ? prms[i].split(':')[idx.to_i].to_s.strip : ''
|
489
|
+
p "Splt : #{prms[i]} => #{idx}" if @dbg[:parse]
|
490
|
+
@new.gsub!(src,rpl)
|
491
|
+
end
|
492
|
+
|
481
493
|
rgx = '\\'+x+'\.([^~ ]+)~' #/\$0\.([^~ ]~)/ => fix: next-tag (~^)
|
482
494
|
eva_v = Regexp.new(rgx) #Ex:$1.upcase~
|
483
495
|
while eva_v=~ "\n#{@new}" do
|
484
496
|
src = "#{x}.#{$1}~" #p "\n#{@new} => #{src}"
|
485
497
|
evl = "\"#{prms[i]}\".#{$1}" #p "====> #{evl} <=="
|
498
|
+
p "Eval : #{evl}" if @dbg[:parse]
|
486
499
|
rpl = prms[i] ? eval(evl).to_s : ""
|
487
500
|
@new.gsub!(src,rpl)
|
488
501
|
end
|
@@ -523,11 +536,11 @@ module W2Tags
|
|
523
536
|
@doc_src = scrpt[1,99]+@doc_src
|
524
537
|
else
|
525
538
|
spc = send[/(^[ \t]*)/,1].to_s
|
526
|
-
rpls << send.gsub(
|
539
|
+
rpls << (send.gsub("\n","\n#{spc}") + "\n")
|
527
540
|
end
|
528
541
|
end
|
529
542
|
end
|
530
|
-
p "End2 : #{rpls
|
543
|
+
p "End2 : #{rpls}" if @dbg[:parse] && rpls!= ''
|
531
544
|
rpls
|
532
545
|
end
|
533
546
|
|
@@ -616,14 +629,16 @@ module W2Tags
|
|
616
629
|
# this var will be use in parsing w2tags/hot command
|
617
630
|
def nameidclass_var()
|
618
631
|
#@key = keys = @rgx[2].strip.gsub(/(\{(.*)\})/,'') #greedy :)
|
619
|
-
@key = keys = @key.strip.gsub(/(\{(.*)\})/,'') #greedy :)
|
632
|
+
@key = keys = @key.strip.gsub(/(\{(.*)\})(=*)/,'') #greedy :)
|
620
633
|
@att = $2.to_s.strip
|
634
|
+
lkey = $3.to_s.strip
|
621
635
|
@mem_var['$$' ]= ''
|
622
636
|
@mem_var['$&' ]= ''
|
623
637
|
@mem_var['$:' ]= ''
|
624
638
|
@mem_var['$#' ]= ''
|
625
639
|
@mem_var['$.' ]= ''
|
626
640
|
@mem_var['$@' ]= $1.to_s
|
641
|
+
@mem_var['$=' ]= ''
|
627
642
|
@mem_var['*&' ]= ''
|
628
643
|
@mem_var['*:' ]= ''
|
629
644
|
@mem_var['*#' ]= ''
|
@@ -675,12 +690,15 @@ module W2Tags
|
|
675
690
|
@mem_var['*all*'] << @mem_var['*@']
|
676
691
|
@mem_var['*att*'] = @mem_var['*@']
|
677
692
|
if @key[0,1]!='='
|
678
|
-
|
693
|
+
@key << lkey
|
694
|
+
if @key.gsub!(/==+$/,'')
|
679
695
|
@mem_var['*code*'] = '<%= "$*" %>'
|
680
696
|
@mem_var['$@']<< "=="
|
697
|
+
@mem_var['$='] = "=="
|
681
698
|
elsif @key.gsub!(/=$/,'')
|
682
699
|
@mem_var['*code*'] = "<%= $* %>"
|
683
700
|
@mem_var['$@']<< "="
|
701
|
+
@mem_var['$='] = "="
|
684
702
|
end
|
685
703
|
end
|
686
704
|
end
|
@@ -704,7 +722,7 @@ module W2Tags
|
|
704
722
|
prms = @rgx[3].to_s.strip
|
705
723
|
if /^\!/ =~ @key
|
706
724
|
@new = (multi_end2(nil)+@spc+@rgx.to_s.gsub('%!','%')).split("\n")
|
707
|
-
swap_last_empt_src_with_end_tg(@new)
|
725
|
+
swap_last_empt_src_with_end_tg(@new) #@new array of src
|
708
726
|
@row = ''
|
709
727
|
else
|
710
728
|
nameidclass_var()
|
@@ -841,7 +859,7 @@ module W2Tags
|
|
841
859
|
else
|
842
860
|
@plt_opt= ''
|
843
861
|
#rtn= true if @selector.select{|f|send(f)}.length>0
|
844
|
-
rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%]*\{.*\}
|
862
|
+
rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%]*\{.*\}=*) *([^\n]*)\n/)
|
845
863
|
rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%=]*) *([^\n]*)\n/)
|
846
864
|
rtn = true if shortcut_equal( /(^[\t ]*)=([\w\-&\/:#.%=]*) *([^\n]*)\n/)
|
847
865
|
|
@@ -1,44 +1,3 @@
|
|
1
|
-
<style>
|
2
|
-
td{padding:0;}
|
3
|
-
.h{display:none;}
|
4
|
-
#content a{font-size:1em;}
|
5
|
-
|
6
|
-
#tryit td{
|
7
|
-
vertical-align:top;}
|
8
|
-
|
9
|
-
textarea {
|
10
|
-
border:0;
|
11
|
-
font-size:11px;
|
12
|
-
line-height:12px;}
|
13
|
-
|
14
|
-
#link{
|
15
|
-
width:200px;}
|
16
|
-
|
17
|
-
textarea.in1{
|
18
|
-
width:400px;}
|
19
|
-
|
20
|
-
textarea.in2{
|
21
|
-
width:450px;
|
22
|
-
height:539px;
|
23
|
-
background-color:#EEEEEE;}
|
24
|
-
|
25
|
-
iframe{height:539px;}
|
26
|
-
#ifr{
|
27
|
-
width:450px;}
|
28
|
-
|
29
|
-
td.i2{
|
30
|
-
border:2px inset;}
|
31
|
-
|
32
|
-
.CodeMirror-line-numbers div{
|
33
|
-
line-height:1.362em;
|
34
|
-
margin: 0;
|
35
|
-
width:20px;
|
36
|
-
text-align:right;
|
37
|
-
padding-right:1px;
|
38
|
-
background:#EE00FF;
|
39
|
-
}
|
40
|
-
|
41
|
-
</style>
|
42
1
|
<div id="content">
|
43
2
|
<table id="tryit">
|
44
3
|
<tr>
|
@@ -164,61 +123,4 @@ td.i2{
|
|
164
123
|
</tr>
|
165
124
|
</table>
|
166
125
|
</div>
|
167
|
-
<script type="text/javascript">
|
168
|
-
var editor1 = null;
|
169
|
-
var editor2 = null;
|
170
|
-
$(function(){
|
171
|
-
$('#btnclick').click(function(){
|
172
|
-
$('#load').show();
|
173
|
-
$.post('/parse',{input : editor1.getCode()},function(data){
|
174
|
-
editor2.setCode(data);
|
175
|
-
$('td.i3').hide();
|
176
|
-
$('td.i2').show();
|
177
|
-
$('#load').hide();
|
178
|
-
});
|
179
|
-
});
|
180
|
-
|
181
|
-
$('a.load').live('click',function(){
|
182
|
-
$('#load').show();
|
183
|
-
var loc= "/w2/"+$(this).attr('loc')+".w2erb.htm";
|
184
|
-
$.get(loc, function(data){
|
185
|
-
editor1.setCode(data);
|
186
|
-
$('#load').hide();
|
187
|
-
});
|
188
|
-
});
|
189
|
-
|
190
|
-
$('a.load2').live('click',function(){
|
191
|
-
$('#load').show();
|
192
|
-
var src= '/w2/'+$(this).attr('loc')+'.hot.html'
|
193
|
-
$('#ifr').attr('src',src);
|
194
|
-
$('td.i2').hide();
|
195
|
-
$('td.i3').show();
|
196
|
-
});
|
197
|
-
|
198
|
-
$('a.load').cluetip({showtitle : false});
|
199
|
-
|
200
|
-
editor1 = CodeMirror.fromTextArea('code1', {
|
201
|
-
parserfile: ["parsew2tags.js"],
|
202
|
-
stylesheet: "/css/rubycolors.css",
|
203
|
-
path: "../js/",
|
204
|
-
lineNumbers: true,
|
205
|
-
textWrapping: false,
|
206
|
-
indentUnit: 4,
|
207
|
-
parserConfig: {},
|
208
|
-
width: '400px',
|
209
|
-
height: '539px'
|
210
|
-
});
|
211
|
-
|
212
|
-
editor2 = CodeMirror.fromTextArea('code2', {
|
213
|
-
parserfile: ["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsehtmlmixed.js"],
|
214
|
-
stylesheet: ["css/xmlcolors.css", "css/jscolors.css", "css/csscolors.css"],
|
215
|
-
path: "../js/",
|
216
|
-
lineNumbers: false,
|
217
|
-
textWrapping: false,
|
218
|
-
indentUnit: 4,
|
219
|
-
parserConfig: {},
|
220
|
-
width: '450px',
|
221
|
-
height: '535px'
|
222
|
-
});
|
223
|
-
});
|
224
|
-
</script>
|
126
|
+
<script type="text/javascript" src="/javascripts/application.js" > </script>
|
@@ -4,6 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta content="text/html; charset=utf-8" http-equiv="Content-type"/>
|
6
6
|
<title>W2tags Try</title>
|
7
|
+
<link rel="stylesheet" href="/stylesheets/application.css" type="text/css" />
|
7
8
|
<link rel="stylesheet" href="/stylesheets/jquery.cluetip.css" type="text/css" />
|
8
9
|
<link rel="stylesheet" href="/stylesheets/jquery.live.accordion.css" type="text/css" />
|
9
10
|
<script type="text/javascript" src="/js/codemirror.js" > </script>
|
data/tasks/setup.rb
CHANGED
@@ -17,7 +17,7 @@ PROJ = OpenStruct.new(
|
|
17
17
|
:authors => 'Widi Harsojo',
|
18
18
|
:email => 'wharsojo@gmail.com',
|
19
19
|
:url => "\000",
|
20
|
-
:version => ENV['VERSION'] || '0.9.
|
20
|
+
:version => ENV['VERSION'] || '0.9.67',
|
21
21
|
:exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/),
|
22
22
|
:release_name => ENV['RELEASE'],
|
23
23
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: w2tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 189
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 67
|
10
|
+
version: 0.9.67
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- widi harsojo
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-05 00:00:00 +07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|