w2tags 0.9.64 → 0.9.65

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.
@@ -36,7 +36,7 @@ some popular patern in view engine, so I change the patern. Now syntax mimics HA
36
36
  to easy transisition, and proven to be useable and best.
37
37
 
38
38
  Extended Syntax are the remain patern before I choose HAML-like syntax like
39
- "^" - NextTag (next tag will be use after using a tag like "ul" next tag "li"),
39
+ "^" or "*" - NextTag (next tag will be use after using a tag like "ul" next tag "li"),
40
40
  Redefinition NextTag command using "~^", define variable "&var=",
41
41
  define uniq variable "@var=", Key-Variable
42
42
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.64
1
+ 0.9.65
@@ -1,6 +1,68 @@
1
1
  = Change Log
2
2
 
3
- Below is a complete listing of changes for each revision of W2TAGS.
3
+ Below is a complete list of changes for each revision of W2TAGS.
4
+
5
+ == 0.9.65
6
+
7
+ === Parser
8
+ * small refactor parser including regexp
9
+ * source code w2tags now can embed hot file
10
+ * nexttag '^' now implement '*' but for reassign still using '~^'
11
+ * nexttag now can redefine/create new global nexttag
12
+
13
+ ==== embed hot file in w2tags code
14
+
15
+ -# Example:
16
+ >>_cok
17
+ %cooook$$ $0
18
+ >>>W2TAGS>>>
19
+ %tr
20
+ ^.c1 column1
21
+ *.c2 column2
22
+
23
+ <tr>
24
+ <th class="c1">column1</th>
25
+ <th class="c2">column2</th>
26
+ </tr>
27
+
28
+ ==== Redefine/create new global nexttag
29
+
30
+ -# Example:
31
+ ~^%tr%td.wheel $0
32
+ %tr
33
+ * roda1
34
+ * roda2
35
+
36
+ <tr>
37
+ <td class="wheel">roda1</td>
38
+ <td class="wheel">roda2</td>
39
+ </tr>
40
+
41
+ ==== Parsing nexttag '^' now support w/o params
42
+
43
+ -# Example:
44
+ %table
45
+ %tr
46
+ ^.c1 column1
47
+ ^.c2
48
+ .last
49
+ %b goood
50
+
51
+ <table>
52
+ <tr>
53
+ <th class="c1">column1</th>
54
+ <th class="c2">
55
+ <div class="last">
56
+ <b>goood</b>
57
+ </div>
58
+ </th>
59
+ </tr>
60
+ </table>
61
+
62
+ == 0.9.64
63
+
64
+ === Parser
65
+ fix loading hot file
4
66
 
5
67
  == 0.9.63
6
68
 
@@ -68,8 +68,12 @@ module W2Tags
68
68
  # <div>Hello Tags</div>
69
69
  # </body>
70
70
  def self.read_filehot(fhot)
71
+ parsing_hot(IO.read(fhot).delete("\r"))
72
+ end
73
+
74
+ def self.parsing_hot(src)
71
75
  hot_new = {}
72
- hot = ("\n"+IO.read(fhot)).delete("\r").split(/\n\>\>/)
76
+ hot = ("\n"+src).split(/\n\>\>/)
73
77
  hot.shift
74
78
  hot.each do |item|
75
79
  item.gsub!(/\n([ \t]*)$/,'') #remove blank lines
@@ -95,6 +99,6 @@ module W2Tags
95
99
  hot_new[keys] = hot
96
100
  end
97
101
  hot_new
98
- end
102
+ end
99
103
  end
100
104
  require 'w2tags/parser'
@@ -22,13 +22,13 @@ module W2Tags
22
22
 
23
23
  #regex for w2tags
24
24
  @rg_tag = [
25
- /^[ \t]*(%)([!]?[\w\-&\/:#.]+\{.*\}[=]*)!([^\n]*)\n/,
26
- /^[ \t]*(%)([!]?[\w\-&\/:#.=]+)!([^\n]*)([\n])/]
25
+ /^[ \t]*(%)([!]?[\w\-&\/:#.\[\]]+\{.*\}[=]*)!([^\n]*)\n/,
26
+ /^[ \t]*(%)([!]?[\w\-&\/:#.\[\]=]+)!([^\n]*)([\n])/]
27
27
 
28
28
  #regex for function tags
29
29
  @rg_hot = [
30
- /(%)([!]?[ \t\$\w\-&\/:#.%=]+\{.*\}[=]*)~([^\n]*)\n/,
31
- /(%)([!]?[ \t\$\w\-&\/:#.%=]+)~([^\n]*)\n/ ]
30
+ /(%)([!]?[ \t\$\w\-&\/:#.\[\]%=]+\{.*\}[=]*)~([^\n]*)\n/,
31
+ /(%)([!]?[ \t\$\w\-&\/:#.\[\]%=]+)~([^\n]*)\n/ ]
32
32
  @rgx = nil #current regular expression
33
33
  @mrg = mrg #another hot to include
34
34
  @ext = 'erb' #target extension
@@ -53,24 +53,6 @@ module W2Tags
53
53
  @doc_src= []
54
54
  @doc_out= []
55
55
 
56
- @tg_nex['html' ]= [0,proc { @mem_tag["^"] = "%head $*\n"}]
57
- @tg_nex['head' ]= [0,proc { @mem_tag["^"] = "%body $*\n"}]
58
- @tg_nex['ol' ]= [0,proc { @mem_tag["^"] = "%li $0\n" }]
59
- @tg_nex['ul' ]= [0,proc { @mem_tag["^"] = "%li $0\n" }]
60
- @tg_nex['dl' ]= [0,proc { @mem_tag["^"] = "%dt $0\n" }]
61
- @tg_nex['dd' ]= [0,proc { @mem_tag["^"] = "%dt $0\n" }]
62
- @tg_nex['form' ]= [0,proc { @mem_tag["^"] = "%input $0\n"}]
63
- @tg_nex['select']= [0,proc { @mem_tag["^"] = "%option $0\n"}]
64
- @tg_nex['table' ]= [0,proc { @tg_nex['tr'][0]= 0 }]
65
- @tg_nex['tr' ]= [0,proc {
66
- @tg_nex['tr' ][0]+= 1
67
- if @tg_nex['tr'][0]== 1
68
- @mem_tag["^"] = "%th $0\n"
69
- else
70
- @mem_tag["^"] = "%td $0\n"
71
- end
72
- }]
73
-
74
56
  @tagr = proc do |this|
75
57
  @key.strip!
76
58
  tags_created = "<#{@key}"
@@ -105,7 +87,42 @@ module W2Tags
105
87
  @skiper << [$1,'_skip'].join.to_sym if /(.*)_skip$/ =~ meth
106
88
  end
107
89
  end
90
+
91
+ #it use to clean all the definition and reloading the hot file
92
+ def parse_init
93
+ @tg_end = [] #momorize tag end from regex function
94
+ @doc_src = []
95
+ @doc_out = []
96
+ @tg_hot = {}
97
+ merge_tags @mrg ? @mrg : @ext
98
+ next_tag_init
99
+ end
100
+
101
+ def next_tag_init
102
+ @tg_nex['html' ]= [0,proc { @mem_tag["^"] = "%head $*\n"}]
103
+ @tg_nex['head' ]= [0,proc { @mem_tag["^"] = "%body $*\n"}]
104
+ @tg_nex['ol' ]= [0,proc { @mem_tag["^"] = "%li $0\n" }]
105
+ @tg_nex['ul' ]= [0,proc { @mem_tag["^"] = "%li $0\n" }]
106
+ @tg_nex['dl' ]= [0,proc { @mem_tag["^"] = "%dt $0\n" }]
107
+ @tg_nex['dd' ]= [0,proc { @mem_tag["^"] = "%dt $0\n" }]
108
+ @tg_nex['form' ]= [0,proc { @mem_tag["^"] = "%input $0\n"}]
109
+ @tg_nex['select']= [0,proc { @mem_tag["^"] = "%option $0\n"}]
110
+ @tg_nex['table' ]= [0,proc { @tg_nex['tr'][0]= 0 }]
111
+ @tg_nex['tr' ]= [0,proc {
112
+ @tg_nex['tr' ][0]+= 1
113
+ if @tg_nex['tr'][0]== 1
114
+ @mem_tag["^"] = "%th $0\n"
115
+ else
116
+ @mem_tag["^"] = "%td $0\n"
117
+ end
118
+ }]
119
+ end
108
120
 
121
+ def read_w2tags(src,spc=nil)
122
+ src = src.delete("\r").split(/\n\>\>\>W2TAGS\>\>\>/)
123
+ @tg_hot.merge!(W2Tags.parsing_hot(src.shift)) if src.length>1
124
+ (spc ? src[0].gsub("\n","\n"+@spc) : src[0])
125
+ end
109
126
  #parsing from fullpath source to the fullpath target/result
110
127
  #with the option of auto add 'initialize' and 'finalize'
111
128
  #for source file in w2tags only fill with LF it will not
@@ -121,7 +138,7 @@ module W2Tags
121
138
  puts ">>#{tgt}"
122
139
  parse_init
123
140
  @src_path= File.dirname(src)
124
- @doc_src = IO.read(src).delete("\r").split("\n")
141
+ @doc_src = read_w2tags(IO.read(src)).split("\n")
125
142
  @doc_src<< "%finallize" if @tg_hot['finallize' ]
126
143
 
127
144
  while (@row = @doc_src.shift) do #;p "row:#{@row}"
@@ -151,21 +168,13 @@ module W2Tags
151
168
 
152
169
  end
153
170
 
154
- #it use to clean all the definition and reloading the hot file
155
- def parse_init
156
- @tg_end = [] #momorize tag end from regex function
157
- @doc_src = []
158
- @doc_out = []
159
- @tg_hot = {}
160
- merge_tags @mrg ? @mrg : @ext
161
- end
162
-
163
171
  #to test parsing on source line and return will be the result,
164
172
  #everytime it execude, it clean up and reloading the HOT files.
165
173
  def parse_line row,init=true
166
174
  parse_init if init
167
175
  dbg[:parse]= false
168
- @doc_src = row.delete("\r").split("\n") << ",/"
176
+ @doc_src = read_w2tags(row).split("\n") << ",/"
177
+ #@doc_src = row.delete("\r").split("\n") << ",/"
169
178
  while (@row= @doc_src.shift) do #;p "row:#{@row}"
170
179
  parse_row
171
180
  end
@@ -351,12 +360,13 @@ module W2Tags
351
360
  #it will include / replace current row from file include, and after
352
361
  #parser will try to get current row after merging to be evaluate
353
362
  def merge_w2x
354
- if(/!inc! *([\/\w._]+)([\n])/ =~ @row;@rgx = $~)
363
+ if(/!inc! *([\/\w\d._]+)([\n])/ =~ @row;@rgx = $~)
355
364
  mac = @src_path+'/'+$1
356
365
  src = $~.to_s #;p mac
357
366
  if File.exist?(mac)
358
367
  pop = $~.captures.pop
359
- new = IO.read(mac).delete("\r").gsub("\n","\n"+@spc)
368
+ #new = IO.read(mac).delete("\r").gsub("\n","\n"+@spc)
369
+ new = read_w2tags(IO.read(mac))
360
370
  @doc_src= @row.gsub(src,new).split("\n")+@doc_src
361
371
  @row= @doc_src.shift+"\n"
362
372
  parse_spc
@@ -468,10 +478,11 @@ module W2Tags
468
478
  else
469
479
  i = new_prms.size - 1
470
480
  new_prms.sort.reverse.each do |x|
471
- eva_v = Regexp.new('\\'+x+'\.([^~]+)~') #$1.upcase~
481
+ rgx = '\\'+x+'\.([^~ ]+)~' #/\$0\.([^~ ]~)/ => fix: next-tag (~^)
482
+ eva_v = Regexp.new(rgx) #Ex:$1.upcase~
472
483
  while eva_v=~ "\n#{@new}" do
473
- src = "#{x}.#{$1}~" ; #p "\n#{@new} => #{src}"
474
- evl = "\"#{prms[i]}\".#{$1}"; #p "====> #{evl} <=="
484
+ src = "#{x}.#{$1}~" #p "\n#{@new} => #{src}"
485
+ evl = "\"#{prms[i]}\".#{$1}" #p "====> #{evl} <=="
475
486
  rpl = prms[i] ? eval(evl).to_s : ""
476
487
  @new.gsub!(src,rpl)
477
488
  end
@@ -624,10 +635,10 @@ module W2Tags
624
635
  @mem_var['*class*']= ''
625
636
  @mem_var['*code*' ]= ''
626
637
  #p keys
627
- if @key.gsub!(/([:#.&=])([\/\t\w\-#.&= ]*$)/,'')
638
+ if @key.gsub!(/([:#.&=])([\/\t\w\-#.\[\]&= ]*$)/,'')
628
639
  keys = $1+$2
629
640
  @mem_var['$$'] = keys.clone
630
- if keys.gsub!(/^:([\w\-.]*)/,'')
641
+ if keys.gsub!(/^:([\w\-.\[\]]*)/,'')
631
642
  if $1!=''
632
643
  @mem_var['$:' ] = ":#{$1}"
633
644
  @mem_var['*:' ] = $1
@@ -834,10 +845,10 @@ module W2Tags
834
845
  rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%=]*) *([^\n]*)\n/)
835
846
  rtn = true if shortcut_equal( /(^[\t ]*)=([\w\-&\/:#.%=]*) *([^\n]*)\n/)
836
847
 
837
- rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.]+\{.*?\}[= ]*)([^\n]*)\n/)
838
- rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.]+\{.*?\}[= ]*)()\n/)
839
- rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.%=]+ )([^\n]*)\n/)
840
- rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.%=]+)()\n/)
848
+ rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]]+\{.*?\}[= ]*)([^\n]*)\n/)
849
+ rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]]+\{.*?\}[= ]*)()\n/)
850
+ rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]%=]+ )([^\n]*)\n/)
851
+ rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]%=]+)()\n/)
841
852
 
842
853
  rtn = true if get_div(/^[\t ]*([#.])([\w\-&\/.]*\{.*\}[= ]*)([^\n]*)\n/)
843
854
  rtn = true if get_div(/^[\t ]*([#.])([\w\-&\/.]*\{.*\}[= ]*)()\n/)
@@ -875,22 +886,39 @@ module W2Tags
875
886
  # ^ inside td
876
887
  #I think its Ok.
877
888
  def parse_set_mem
878
- if @row.gsub!(/([ \t]*~\^)([^\n]+)(\n)/,'')
879
- p "setMem ^ => #{$2+"\n"}" if @dbg[:parse]
880
- @mem_tag["^"]= $2+"\n"
889
+ if @row.gsub!(/([ \t]*~\^)([^\n]+\n)/,'')
890
+ set_mem = $2
891
+ if !global_set_mem(set_mem)
892
+ p "setMem ^ => #{set_mem}" if @dbg[:parse]
893
+ @mem_tag["^"]= set_mem
894
+ end
881
895
  end
882
896
  end
883
897
 
884
- #call from parse_get_mem
885
- def get_mem(regex)
886
- if(regex =~ @row;@rgx = $~)
898
+ def global_set_mem(set_mem)
899
+ return nil if !(/^%(\w+)([%-].+)/ =~ set_mem)
900
+ @tg_nex[$1]= [0,proc { @mem_tag["^"] = $2}]
901
+ end
902
+
903
+ #remember command "^", not really use but if you want less typing you can
904
+ #define this command inside HOT file for the next command to be execute like:
905
+ # HOT file:
906
+ # >>_tr
907
+ # ~^%td
908
+ #
909
+ # Source file:
910
+ # -tr
911
+ # ^ inside td
912
+ #I think its Ok.
913
+ def parse_get_mem
914
+ if(/([\^*])([^ ]*) *([^\n]*)(\n)/ =~ @row;@rgx = $~)
887
915
  keys,tmp,prms,opt,ends= @rgx.captures
888
916
  if opt=='!'
889
917
  opt=''
890
918
  @mem_hot=nil
891
919
  end
920
+ keys.sub!('*','^')
892
921
  params_inline prms #concenation line if params end with \
893
-
894
922
  @new = @mem_tag[keys].split(' ')
895
923
  @new[0] << tmp
896
924
  @new = @new.join(" ") << "\n"
@@ -907,20 +935,6 @@ module W2Tags
907
935
  @rgx!=nil
908
936
  end
909
937
 
910
- #remember command "^", not really use but if you want less typing you can
911
- #define this command inside HOT file for the next command to be execute like:
912
- # HOT file:
913
- # >>_tr
914
- # ~^%td
915
- #
916
- # Source file:
917
- # -tr
918
- # ^ inside td
919
- #I think its Ok.
920
- def parse_get_mem
921
- get_mem(/([\^])([^ ]*) ([^\n]*)(\n)/)
922
- end
923
-
924
938
  #it call from parse_end
925
939
  def get_end(regex)
926
940
  if(regex =~ @row;@rgx = $~)
@@ -4,12 +4,14 @@ var CSSParser = Editor.Parser = (function() {
4
4
  var tokenizeCSS = (function() {
5
5
  function normal(source, setState) {
6
6
  var ch = source.next();
7
+ if (ch == "\>" && source.equals("\>")) { source.nextWhileMatches(/./); return "rb-symbol"; } else
7
8
  if (ch == "-" && source.equals("#")) { source.nextWhileMatches(/./); return "rb-comment"; } else
8
9
  if (ch == ":") { source.nextWhileMatches(/[\w-]/); return "rb-method-parameter"; } else
9
10
  if (ch == "#") { source.nextWhileMatches(/[\w-]/); return "rb-constant"; } else
10
11
  if (ch == ".") { source.nextWhileMatches(/[\w-]/); return "rb-method"; } else
11
12
  if (ch == "-") { source.nextWhileMatches(/\w/); return "rb-symbol"; } else
12
13
  if (ch == "^") { source.nextWhileMatches(/\w/); return "rb-symbol"; } else
14
+ if (ch == "*") { source.nextWhileMatches(/\w/); return "rb-symbol"; } else
13
15
  if (ch == "%") { source.nextWhileMatches(/\w/); return "rb-keyword"; } else
14
16
  if (ch == "=") { source.nextWhileMatches(/\w/); return "rb-operator"; } else
15
17
  if (ch == "@") { source.nextWhileMatches(/\w/); return "rb-keyword"; } else
@@ -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.64',
20
+ :version => ENV['VERSION'] || '0.9.65',
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: 187
4
+ hash: 185
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 64
10
- version: 0.9.64
9
+ - 65
10
+ version: 0.9.65
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: 2010-12-15 00:00:00 +07:00
18
+ date: 2010-12-20 00:00:00 +07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21