AoBane 0.1.14 → 0.1.15

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/AoBane.icns ADDED
Binary file
data/AoBane.jpg ADDED
Binary file
data/AoBane.tiff ADDED
Binary file
data/lib/AoBane.rb CHANGED
@@ -52,9 +52,9 @@ require 'math_ml/string'
52
52
 
53
53
 
54
54
  module AoBane
55
- VERSION = '0.1.14'
56
- VERSION_NUMBER = 0.0114
57
- RELEASE_DATE = '2013-04-24'
55
+ VERSION = '0.1.15'
56
+ VERSION_NUMBER = 0.0115
57
+ RELEASE_DATE = '2013-05-07'
58
58
  VERSION_LABEL = "#{VERSION} (#{RELEASE_DATE})"
59
59
 
60
60
  UTF8_BOM = "\xef\xbb\xbf"
@@ -523,44 +523,23 @@ module AoBane
523
523
  text += "\n\n"
524
524
  @log.debug "Normalized line-endings: %p" % text
525
525
 
526
- #Insert by set.minami 2013-03-30
527
- text.gsub!(/\*\[(.*?)\]\((.*?)(\|.*?)*(\/.*?)*\)/){|match|
528
- '<font color="' +
529
- if $2.nil? then '' else $2 end +'" ' +
530
- 'face="' +
531
- if $3.nil? then '' else $3.delete('|') end + '" ' +
532
- 'size="' +
533
- if $4.nil? then '' else $4.delete('/') end + '">' +
534
- $1 + '</font>'
535
- }
536
- #Insert by set.minami 2013-04-13
537
- text = Utilities::prePaling(text)
538
- #Insert by set.minami 2013-04-21
539
- text = Utilities::abbrPreProcess(text)
540
- #Insert by set.minami 2013-04-01
541
- text.gsub!(/\\TeX\{(.+?)\\TeX\}/){
542
- begin
543
- $1.to_mathml
544
- rescue => e
545
- puts 'math_ml Error: ' + $1
546
- puts e
547
- end
548
- }
549
-
526
+ #text = Utilities::prePaling(text) #Insert by set.minami 2013-04-27
550
527
  #Insert by set.minami 2013-04-03
551
528
  nrange = []
552
529
  departure = 1
553
530
  preproc = Marshal.load(Marshal.dump(text))
554
531
  text.clear
532
+ stack = []
555
533
  html_text_number = 0
534
+ # Utilities::initNumberStack
535
+
556
536
  preproc.lines { |line|
557
537
  html_text_number += 1
558
538
  begin
559
- line.gsub!(/^\{nrange:(.*?)(;\d+){0,1}\}/){ |match|
560
- depNum = $2.delete(';').to_i
561
- departure =
562
- if depNum > 0 then depNum else 1 end
563
- if /[hH]([1-6])\-[hH]([1-6])/ =~ $1
539
+ line.gsub!(/^\{nrange:(.*?)(;\d+)??\}/){ |match|
540
+ #depNum = $2.delete(';').to_i
541
+ #departure = if depNum > 0 then depNum else 1 end
542
+ if /h(\d)\-h(\d)/i =~ $1
564
543
  nrange.push($1)
565
544
  nrange.push($2)
566
545
  if nrange.size > 2 then
@@ -580,18 +559,43 @@ module AoBane
580
559
  "@ l.#{html_text_number}";exit(-1)
581
560
  raise FatalError,"AoBane Syntax Error:Header range is WRONG!"
582
561
  end
583
- line.gsub!(/^(%{1,#{range}})(.*?)\n$/){ |match|
584
- line = Utilities.
585
- calcSectionNo(nrange.min,range,$1.size,departure,$2)
586
- }
587
- text << line
562
+ if line =~ /^(%{1,#{range}})(.*?)\n/ then
563
+ text << Utilities.
564
+ calcSectionNo(nrange.min,range,$1.size,departure,$2,stack) +
565
+ "\n"
566
+ else
567
+ text << line
568
+ end
588
569
  @log.debug nrange.minmax
589
570
  rescue => e
590
571
  @log.warn "AoBane Syntax WARNING l.#{html_text_number}:#{line.chomp} haven't adopted"
591
572
  @log.warn e
592
573
  end
593
574
  }
594
-
575
+
576
+ text.gsub!(/\*\[(.*?)\]\((.*?)(\|.*?)*(\/.*?)*\)/){|match|
577
+ '<font color="' +
578
+ if $2.nil? then '' else $2 end +'" ' +
579
+ 'face="' +
580
+ if $3.nil? then '' else $3.delete('|') end + '" ' +
581
+ 'size="' +
582
+ if $4.nil? then '' else $4.delete('/') end + '">' +
583
+ $1 + '</font>'
584
+ }
585
+ #Insert by set.minami 2013-04-21
586
+ text = Utilities::abbrPreProcess(text)
587
+ #Insert by set.minami 2013-04-01
588
+ text.gsub!(/\\TeX\{(.+?)\\TeX\}/){
589
+ begin
590
+ $1.to_mathml
591
+ rescue => e
592
+ puts 'math_ml Error: ' + $1
593
+ puts e
594
+ end
595
+ }
596
+
597
+ text = Utilities::preProcFence(text,0).join("\n") #Insert by set.minami 2013-04-27
598
+ #Insert by set.minami 2013-03-30
595
599
  #Insert by set.minami
596
600
 
597
601
  # Filter HTML if we're asked to do so
@@ -657,75 +661,15 @@ module AoBane
657
661
  end
658
662
  end
659
663
 
660
- #Insert by Set.Minami 2013-04-13
661
- text = Utilities::postPaling(text)
662
664
  #Insert by set.minami 2013-04-21
663
665
  text = Utilities::abbrPostProcess(text)
664
666
  #Insert by set.minami 2013-03-30
665
667
  text = Utilities::insertTimeStamp(text)
666
-
667
- #output = text.split("\n")
668
- specialChar = {
669
- "\-\-" => "&mdash;",
670
- "<=" => "&hArr;",
671
- "<\->" => "&harr;",
672
- "\->" =>"&rarr;",
673
- "<\-" =>"&larr;",
674
- "=>" => "&rArr;",
675
- "<=" => "&lArr;",
676
- "\|\|\^" => "&uArr;",
677
- "\|\|\/" => "&dArr;",
678
- "\|\/" => "&darr;",
679
- "\|\^" => "&uarr;",
680
- ">>" => "&raquo;",
681
- "\<\<" => "&laquo;",
682
- "+_" => "&plusmn;",
683
- "!=" => "&ne;",
684
- "~~" => "&asymp;",
685
- "~=" => "&cong;",
686
- "<_" => "&le;",
687
- ">_" => "&ge",
688
- "\|FA" => "&forall;",
689
- "\|EX" => "&exist;",
690
- "\|=" => "&equiv;",
691
- "\(+\)" => "&oplus",
692
- "\(x\)" => "&otimes;",
693
- "\(c\)" => "&copy;",
694
- "\(R\)" =>"&reg;",
695
- "\(SS\)" => "&sect;",
696
- "\(TM\)" => "&trade;",
697
- "!in" => "&notin;"}
668
+ text = Utilities::postProcFence(text) #Insert by set.minami 2013-04-27
698
669
 
699
- entry = '\-\-|<=>|<\->|\->|<\-|=>|<=|\|\^|\|\|\/|\|\/|\^|\>\>|\<\<|\+_|!=|~~|~=|>_|<_|\|FA|\|EX|\|=|\(+\)|\(x\)|\(c\)|\(R\)|\(SS\)|\(TM\)|!in'
670
+ text = Utilities::transformSpecialChar(text) #Insert by set.minami 2013-04-27
700
671
 
701
- if text =~ /<pre>/i then
702
- text.gsub!(/<\/pre>(.*?)<pre>/i){|m|
703
- if m.nil? then '<\/pre><pre>'
704
- else
705
- '<\/pre>' + m.gsub!(/#{entry}/,specialChar).to_s + '<pre>'
706
- end
707
- }
708
- text.gsub!(/<\/pre>(.*?)/i){|m|
709
- if m.nil? then '<\/pre>'
710
- else
711
- '</pre>' + m.gsub!(/#{entry}/,specialChar).to_s
712
- end
713
- }
714
- text.gsub!(/(.*?)<pre>/i){|m|
715
- if m.nil? then '<pre>'
716
- else
717
- m.gsub!(/#{entry}/,specialChar).to_s + '<pre>'
718
- end
719
- }
720
- else
721
- if text.nil? then ''
722
- else text.gsub!(/#{entry}/,specialChar)
723
- end
724
- end
725
- #return output.join("\n")
726
- #Insert by set.minami
727
- return text
728
-
672
+ return text
729
673
  end
730
674
 
731
675
  alias parse parse_text
@@ -879,6 +823,7 @@ module AoBane
879
823
 
880
824
  @log.debug "Applying block transforms to:\n %p" % str
881
825
  text = str
826
+
882
827
  text = pretransform_fenced_code_blocks( text, rs )
883
828
  text = pretransform_block_separators(text, rs)
884
829
 
@@ -1231,12 +1176,11 @@ module AoBane
1231
1176
  }
1232
1177
  end
1233
1178
 
1234
- CaptionRegexp = "\\[(.+?)\\](\\{\\#(.+?)\\}){0,1}"
1179
+ CaptionRegexp = '\[(.+?)\](\{(.+?)\})??'
1235
1180
  TableRegexp = %r{
1236
1181
  (?:
1237
- (#{CaptionRegexp}\s*\n){0,1}
1238
- # modified by set.minami 2013-04-20
1239
- ^([ ]{0,#{TabWidth - 1}}) # not indented
1182
+ (#{CaptionRegexp}\s*\n)??# modified by set.minami 2013-04-20
1183
+ ([ ]{0,#{TabWidth - 1}}) # not indented
1240
1184
  (?:[|][ ]*) # NOT optional border
1241
1185
 
1242
1186
  \S.*? # 1st cell content
@@ -1253,9 +1197,9 @@ module AoBane
1253
1197
 
1254
1198
  # Transform tables.
1255
1199
  def transform_tables(str, rs)
1256
- str.gsub(TableRegexp){
1257
- transform_table_rows($~[0], rs)
1258
- }
1200
+ str.gsub(TableRegexp){
1201
+ transform_table_rows($~[0], rs)
1202
+ }
1259
1203
  end
1260
1204
 
1261
1205
  TableSeparatorCellRegexp = %r{
@@ -1271,79 +1215,86 @@ module AoBane
1271
1215
  }x
1272
1216
 
1273
1217
  def transform_table_rows(str, rs)
1274
-
1275
- # split cells to 2-d array
1276
- data = str.split("\n").map{|x| x.split('|')}
1277
- caption = '' #Inserted by set.minami 2013-04-20
1278
- captionName = ''
1279
- if /#{CaptionRegexp}/ =~ data[0][0] then
1280
- caption = if $1.nil? then '' else $1 end
1281
- captionName = if $3.nil? then '' else $3 end
1282
- data.slice!(0)
1283
- end #Inserted by set.minami 2013-04-20
1284
- data.each do |row|
1285
- # cut left space
1286
- row.first.lstrip!
1287
-
1288
- # cut when optional side-borders is included
1289
- row.shift if row.first.empty?
1290
- end
1291
-
1292
- column_attrs = []
1293
-
1294
- re = ''
1295
- re << if captionName == '' then
1296
- "<table>\n"
1297
- else
1298
- "<table id=\"#{captionName}\">\n"
1299
- end
1300
- re << "<caption>#{caption}</caption>\n"
1301
- #Insert by set.minami 2013-04-20
1302
-
1303
- # head is exist?
1304
- if data.size >= 3 and data[1].all?{|x| x =~ TableSeparatorCellRegexp} then
1305
- head_row = data.shift
1306
- separator_row = data.shift
1307
-
1308
- separator_row.each do |cell|
1309
- cell.match TableSeparatorCellRegexp
1310
- left = $1; right = $2
1311
-
1312
- if left and right then
1313
- column_attrs << ' style="text-align: center"'
1314
- elsif right then
1315
- column_attrs << ' style="text-align: right"'
1316
- elsif left then
1317
- column_attrs << ' style="text-align: left"'
1318
- else
1319
- column_attrs << ''
1320
- end
1321
- end
1322
-
1323
- re << "\t<thead><tr>\n"
1324
- head_row.each_with_index do |cell, i|
1325
- re << "\t\t<th#{column_attrs[i]}>#{apply_span_transforms(cell.strip, rs)}</th>\n"
1326
- end
1327
- re << "\t</tr></thead>\n"
1328
- end
1329
-
1330
- # data row
1331
- re << "\t<tbody>\n"
1332
- data.each do |row|
1333
- re << "\t\t<tr>\n"
1334
- row.each_with_index do |cell, i|
1335
- re << "\t\t\t<td#{column_attrs[i]}>#{apply_span_transforms(cell.strip, rs)}</td>\n"
1336
- end
1337
- re << "\t\t</tr>\n"
1338
- end
1339
- re << "\t</tbody>\n"
1340
-
1341
- re << "</table>\n"
1342
-
1343
- re
1218
+ # split cells to 2-d array
1219
+ data = str.split("\n").map{|x| x.split('|')}
1220
+ caption = '' #Inserted by set.minami 2013-04-20
1221
+ captionName = ''
1222
+ if /#{CaptionRegexp}/ =~ data[0].first then
1223
+ caption = if $1.nil? then '' else $1 end
1224
+ captionName = if $3.nil? then '' else $3 end
1225
+ data.shift
1226
+ end #Inserted by set.minami 2013-04-20
1227
+ data.each do |row|
1228
+ if row.first.nil? then next end
1229
+ # cut left space
1230
+ row.first.lstrip!
1231
+
1232
+ # cut when optional side-borders is included
1233
+ row.shift if row.first.empty?
1234
+ end
1235
+
1236
+ column_attrs = []
1237
+
1238
+ re = ''
1239
+ re << if captionName == '' then
1240
+ "<table>\n"
1241
+ else
1242
+ "<table id=\"#{captionName}\">\n"
1243
+ end
1244
+ re << "<caption>#{caption}</caption>\n"
1245
+ #Insert by set.minami 2013-04-20
1246
+
1247
+ # head is exist?
1248
+
1249
+ #if !data[1].nil? && data[1].last =~ /\s+/ then
1250
+ ### p data
1251
+ # data.each{|d|
1252
+ # d.pop
1253
+ # }
1254
+ #end #Insert by set.minami @ 2013-04-29
1255
+ if data.size >= 3 and data[1].all?{|x| x =~ TableSeparatorCellRegexp} then
1256
+ head_row = data.shift
1257
+ separator_row = data.shift
1258
+
1259
+ separator_row.each do |cell|
1260
+ cell.match TableSeparatorCellRegexp
1261
+ left = $1; right = $2
1262
+
1263
+ if left and right then
1264
+ column_attrs << ' style="text-align: center"'
1265
+ elsif right then
1266
+ column_attrs << ' style="text-align: right"'
1267
+ elsif left then
1268
+ column_attrs << ' style="text-align: left"'
1269
+ else
1270
+ column_attrs << ''
1271
+ end
1272
+ end
1273
+
1274
+ re << "\t<thead><tr>\n"
1275
+ head_row.each_with_index do |cell, i|
1276
+ re << "\t\t<th#{column_attrs[i]}>#{apply_span_transforms(cell.strip, rs)}</th>\n"
1277
+ end
1278
+ re << "\t</tr></thead>\n"
1279
+ end
1280
+
1281
+ # data row
1282
+ re << "\t<tbody>\n"
1283
+ data.each do |row|
1284
+ re << "\t\t<tr>\n"
1285
+ row.each_with_index do |cell, i|
1286
+ re << "\t\t\t<td#{column_attrs[i]}>#{apply_span_transforms(cell.strip, rs)}</td>\n"
1287
+ end
1288
+ re << "\t\t</tr>\n"
1289
+ end
1290
+ re << "\t</tbody>\n"
1291
+
1292
+ re << "</table>\n"
1293
+
1294
+ re
1344
1295
  end
1345
1296
 
1346
-
1297
+
1347
1298
  ### Transform any Markdown-style horizontal rules in a copy of the specified
1348
1299
  ### +str+ and return it.
1349
1300
  def transform_hrules( str, rs )
@@ -15,6 +15,66 @@ module Utilities
15
15
  $MAX_H = 6
16
16
  @@log = Logger.new(STDOUT)
17
17
  @@log.level = Logger::WARN
18
+
19
+ def transformSpecialChar(text)
20
+ #output = text.split("\n")
21
+ specialChar = {
22
+ "\-\-" => "&mdash;",
23
+ "<=" => "&hArr;",
24
+ "<\->" => "&harr;",
25
+ "\->" =>"&rarr;",
26
+ "<\-" =>"&larr;",
27
+ "=>" => "&rArr;",
28
+ "<=" => "&lArr;",
29
+ "\|\|\^" => "&uArr;",
30
+ "\|\|\/" => "&dArr;",
31
+ "\|\/" => "&darr;",
32
+ "\|\^" => "&uarr;",
33
+ ">>" => "&raquo;",
34
+ "\<\<" => "&laquo;",
35
+ "+_" => "&plusmn;",
36
+ "!=" => "&ne;",
37
+ "~~" => "&asymp;",
38
+ "~=" => "&cong;",
39
+ "<_" => "&le;",
40
+ ">_" => "&ge",
41
+ "\|FA" => "&forall;",
42
+ "\|EX" => "&exist;",
43
+ "\|=" => "&equiv;",
44
+ "\(\+\)" => "&oplus;",
45
+ "\(\-\)" => "&ominus;",
46
+ "\(X\)" => "&otimes;",
47
+ "\(c\)" => "&copy;",
48
+ "\(R\)" =>"&reg;",
49
+ "\(SS\)" => "&sect;",
50
+ "\(TM\)" => "&trade;",
51
+ "!in" => "&notin;"}
52
+
53
+ entry = '(?!\-+\|)\-\-|<=>|<\->|\->|<\-|=>|<=|\|\^|\|\|\/|\|\/|\^|\>\>|\<\<|' +
54
+ '\+_|!=|~~|~=|>_|<_|\|FA|\|EX|\|=|\(\+\)|\(\-\)|\(X\)|\(c\)|\(R\)|\(SS\)|\(TM\)|!in'
55
+
56
+
57
+
58
+ zoneofPre = ["<pre>","<\/pre>"]
59
+ dup = []
60
+ doc = text.split("\n")
61
+ index = 0
62
+ doc.each{
63
+ if doc[index] =~ /#{zoneofPre[0]}/i
64
+ until doc[index] =~ /#{zoneofPre[1]}/i
65
+ dup[index] = doc[index]
66
+ index += 1
67
+ end
68
+ dup[index] = doc[index]
69
+ else
70
+ dup[index] = if !doc[index].nil? then doc[index].gsub(/#{entry}/,specialChar) end
71
+ index += 1
72
+ end
73
+ }
74
+
75
+ #Insert by set.minami
76
+ return dup.join("\n")
77
+ end
18
78
  ###Insert Timestamp#################################################################
19
79
  def insertTimeStamp(text)
20
80
  if /\$date/i =~ text then
@@ -78,37 +138,81 @@ def abbrPostProcess(text)
78
138
  end
79
139
  end
80
140
  ###paling proccessing##########################################################
81
- StartDivMark =
82
- '\|\-:b=(\d+?)\s(\w+?\s\w+?\s)' +
83
- '(w=(\w+?)\s){0,1}' +
84
- '(h=(\w+?)\s){0,1}' +
85
- '(bg=((#){0,1}\w+?)\s){0,1}' +
86
- '(lh=([\w%]+?)\s){0,1}' +
87
- 'rad=(\d+?)\-+\|'
88
- EndDivMark = '\|\-+\|'
89
-
90
- def prePaling(text)
91
- output = text.split("\n")
141
+ StartDivMark =
142
+ '[\/\|]\-:b=(\d+?)\s(\w+?\s\w+?\s)' + # $1 $2
143
+ '(w=(\w+?)\s)??' + # $3 $4
144
+ '(h=(\w+?)\s)??' + # $5 $6
145
+ '(bg=((#)??\w+?)\s)??' + # $7 $8 $9
146
+ '(lh=([\w%]+?)\s)??' + # $10 $11
147
+ '(mg=(\d+?)\s)??' + # $12 $13
148
+ '(al=(\w+?)\s)??' + # $14 $15
149
+ '(rad=(\d+?))\-+[\|\/]' + # $16 $17
150
+ '({(.+?)})??' # $18 $19
151
+ EndDivMark = '\|\_+\|'
152
+ AllChar = '\w\s\!@\#\$%\^&\*\(\)\-\+=\[\{\}\];:\'"<>\,\.\/\?\\|'
153
+ InnerRepresent = ["@","/"]
154
+
155
+ def preProcFence(text,startPoint)
156
+ output = []
157
+ dup = []
158
+ isInFence = [false]
159
+ linePointer = 0
160
+ exclude = '(?!^\|_+|\|\-:)^\||^[#]{1,6}\s|^\s+\*|^\s+\-'
161
+ if !text.instance_of?(Array) then output = text.split("\n") else output = text end
162
+
92
163
  output.each_with_index{|line,index|
93
- if /#{StartDivMark}/ =~ line then
94
- loop do
95
- index += 1
96
- if /#{EndDivMark}/ =~ output[index] then
97
- break
98
- elsif /^\|(\#{1,6})\s*(.*)\|/ =~ output[index] then
99
- output[index] = '#'*$1.size + $2 #pass through to BlueFeather
100
- elsif /^\|(\s*)\*(\s.+?)\s*\|/ =~ output[index] then
101
- output[index] = $1 + '*' + $2 #pass through to BlueFeather
102
- elsif /^\|(\s*)\-(\s.+?)\s*\|/ =~ output[index] then
103
- output[index] = $1 + '-' + $2 #pass through to BlueFeather
104
- elsif /^\|(.*\s*)\|/ =~ output[index] then
105
- output[index] = $1
164
+ if index < startPoint then next
165
+ elsif /#{StartDivMark}/ =~ line then
166
+ start = line.split("|")
167
+ dup << "/" + start[1] + "/"
168
+ if start.size >= 2 then dup << start[2..-1] end
169
+ isInFence.push(true)
170
+ next
171
+ elsif /#{EndDivMark}/ =~ line then
172
+ dup << '/@/'
173
+ next
174
+ else
175
+ if isInFence.last then
176
+ if dup.last.nil? then
177
+ dup << compressWSpaces(line)
178
+ else
179
+ if dup.last =~ /#{exclude}/i || line =~ /#{exclude}/i then
180
+ if line =~ /#{exclude}/i then dup << line
181
+ else dup << compressWSpaces(line) end
182
+ else
183
+ if line == "" then
184
+ dup << '<br />'
185
+ else
186
+ dup.last << compressWSpaces(line)
187
+ next
188
+ end
189
+ end
106
190
  end
191
+ else
192
+ dup << if !line.nil? then line else "" end
193
+ end
107
194
  end
108
- end #if
109
195
  }
110
- return output.join("\n")
111
- end #def prePaling
196
+ return dup
197
+ end
198
+
199
+ def compressWSpaces(line)
200
+ dup = if line =~ /\s+$/ then line.strip + " " else line end
201
+ return dup
202
+ end
203
+
204
+
205
+ # Pattern to match strong emphasis in Markdown text
206
+ BoldRegexp = %r{ (\*\*) (\S|\S.*?\S) \1 }x
207
+
208
+ # Pattern to match normal emphasis in Markdown text
209
+ ItalicRegexp = %r{ (\*) (\S|\S.*?\S) \1 }x
210
+
211
+ def italic_and_bold(str)
212
+ str.
213
+ gsub( BoldRegexp, %{<strong>\\2</strong>} ).
214
+ gsub( ItalicRegexp, %{<em>\\2</em>} )
215
+ end
112
216
 
113
217
  def isDigit(str)
114
218
  if /\d+/ =~ str then
@@ -118,7 +222,7 @@ def isDigit(str)
118
222
  end
119
223
  end
120
224
 
121
- def postPaling(text)
225
+ def postProcFence(text)
122
226
  output = text.split("\n")
123
227
  output.each_with_index{|line,index|
124
228
  if /#{StartDivMark}/ =~ line then
@@ -127,22 +231,33 @@ def postPaling(text)
127
231
  if $6.nil? then '' else 'height:' + if Utilities::isDigit($6) then $6 + 'px;' else $6 + ';' end end +
128
232
  if $8.nil? then '' else 'background-color:' + $8 + ';' end +
129
233
  if $11.nil? then 'line-height:100%;' else 'line-height:' + $11 + ';' end +
234
+ if $13.nil? then '' else 'margin:' + $13 + 'px;' end +
235
+ if $15.nil? then '' else 'text-align:' + $15 + ';' end +
130
236
  'border-radius:' +
131
- if $12.nil? then '' else $12 end + 'px;">'
132
- loop do
133
- index += 1
134
- if /#{EndDivMark}/ =~ output[index] then
135
- output[index] = '</div>'
237
+ if $16.nil? then '' else $16 end + 'px;"' +
238
+ if $19.nil? then '' else 'class="#{$19}"' end +
239
+ '>'
240
+ output.each_with_index{|l,i = index|
241
+ if /\/@\// =~ l then
242
+ output[i] = '</div>'
243
+ index = i
136
244
  break
137
245
  end
138
- end
246
+ i += 1
247
+ }
139
248
  end
140
249
  }
141
250
  return output.join("\n")
142
- end #def postPailing
251
+ end #def postProcFence
252
+
253
+ ### Initialize a Stack class ############################
254
+ def initNumberStack
255
+ Stack.destroy
256
+ end
257
+
143
258
  ### Return a caluculated section number and string.############################
144
- def calcSectionNo(startNo=1, range=0, size=0, dep=1, str='')
145
- stack = Stack.instance
259
+ def calcSectionNo(startNo=1, range=0, size=0, dep=1, str='', outerStack)
260
+ stack = outerStack #Stack.instance
146
261
  i = dep.to_i
147
262
  counter = 0
148
263
  numberStr = [["%",i,counter],["%%",i,counter],["%%%",i,counter],
@@ -154,25 +269,30 @@ end #def postPailing
154
269
  @@log.error("AoBane Syntax Error: Header shortage!")
155
270
  raise SyntaxError,"Headder shortage!"
156
271
  else
157
- (1..size).each_with_index{|k| #h1 to h6
158
- @@log.debug "k #{k},hn #{headNo},s #{size},sN #{startNo},sos #{stack.sizeofStack}"
272
+ (1..headNo).each_with_index{|k| #h1 to h6
273
+ p k
159
274
  if (k < headNo) then
160
- @@log.debug "+++ #{k},#{stack.sizeofStack}"
161
- if k >= stack.sizeofStack then
275
+ p "+++" # #{k},#{stack.sizeofStack}"
276
+ if k >= stack.size then
162
277
  stack.push(numberStr[k])
163
278
  end
164
- elsif (k == headNo) then
165
- if stack.sizeofStack == 0 then
279
+ elsif k == headNo then
280
+ p "---"
281
+ if stack.size == 0 then
166
282
  stack.push(numberStr[k-1])
167
283
  end
168
- if (stack.evalStackTop[$S_SLOT].size > numberStr[k-1][$S_SLOT].size) then
169
- stack.pop
284
+ if stack.last[$S_SLOT].size > numberStr[k-1][$S_SLOT].size then
285
+ loop do
286
+ stack.pop
287
+ if stack.last[$S_SLOT].size == numberStr[k-1][$S_SLOT].size then
288
+ break
289
+ end
290
+ end
170
291
  end
171
292
  else
172
- @@log.debug "~~~~"
293
+ p "~~~~"
173
294
  stack.push(numberStr[k])
174
295
  end #if...elsif
175
- stack.dump
176
296
  }
177
297
  =begin
178
298
  else
@@ -181,22 +301,35 @@ end #def postPailing
181
301
  end #case
182
302
  =end
183
303
  end #if...else
184
- @@log.debug "$$$$"
185
- number = stack.insertNumber
304
+ p "$$$$"
305
+ number = ""
306
+ stack.each { |item|
307
+ if item == stack.last then
308
+ item[$N_SLOT] += item[$C_SLOT]
309
+ item[$C_SLOT] = 1
310
+ end
311
+ number << (item[$N_SLOT]).to_s + '.'
312
+ @@log.debug number
313
+ }
314
+
186
315
  h = "#"
187
316
  times = startNo.to_i + size.to_i - 1
188
317
  return h*times + number + str
189
318
  end #def
190
319
 
320
+ module_function:compressWSpaces
321
+ module_function:italic_and_bold
322
+ module_function:transformSpecialChar
191
323
  module_function:getNowTime
192
324
  module_function:insertTimeStamp
193
325
  module_function:abbrPreProcess
194
326
  module_function:abbrPostProcess
195
327
  module_function:storeAbbr
328
+ module_function:initNumberStack
196
329
  module_function:calcSectionNo
197
- module_function:prePaling
330
+ module_function:preProcFence
198
331
  module_function:isDigit
199
- module_function:postPaling
332
+ module_function:postProcFence
200
333
  #############################################################################
201
334
  end
202
335
 
@@ -234,16 +367,7 @@ class Stack
234
367
  end
235
368
 
236
369
  def insertNumber
237
- str = ""
238
- @stack.each { |item|
239
- if isTopofStack(item) then
240
- item[$N_SLOT] += item[$C_SLOT]
241
- item[$C_SLOT] = 1
242
- end
243
- str << (item[$N_SLOT]).to_s + '.'
244
- @@log.debug str
245
- }
246
- return str
370
+ # return str
247
371
  end
248
372
 
249
373
  def evalStackTop
@@ -268,9 +392,15 @@ class Stack
268
392
  end
269
393
  end
270
394
 
271
- def dump
395
+ def self.dump
272
396
  @@log.debug("Stack DUMP:#{@stack}")
273
397
  end
274
398
 
399
+ def self.destroy
400
+ if @stack.nil? then @stack = [] else @stack.clear end
401
+ p @stack
402
+ @sp = 0
403
+ end
404
+
275
405
  end
276
406
 
@@ -1,3 +1,3 @@
1
1
  module AoBane
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
data/test/Test.html CHANGED
@@ -8,7 +8,22 @@
8
8
 
9
9
  <ul>
10
10
  <li><a href="#bfheader-0cbc6611f5540bd0809a388dc95a615b" rel="toc">Test</a>
11
- * <a href="#bfheader-acbd18db4cc2f85cedef654fccc4a4d8" rel="toc">foo</a></li>
11
+ <ul>
12
+ <li><a href="#bfheader-f2b20ed74117a2bda0525514a898e0e0" rel="toc">1. &rarr;1.</a>
13
+ <ul>
14
+ <li><a href="#bfheader-4e7b97bf9819709771ba6c716991e3ef" rel="toc">1.1. &rarr;1.1.</a></li>
15
+ <li><a href="#bfheader-a4940c538c7be252daf50cc4237617ce" rel="toc">1.2. &rarr;1.2.</a>
16
+ <ul>
17
+ <li><a href="#bfheader-b162ec5d01c9e20e3551a5b96fa9f650" rel="toc">1.2.1. &rarr;1.2.1.</a></li>
18
+ <li><a href="#bfheader-584eba1c1d454adaca0318b151a2dcb2" rel="toc">1.2.2. &rarr;1.2.2.</a></li>
19
+ </ul></li>
20
+ <li><a href="#bfheader-9868f67e1aa2e9e7d90a9a4846b8558f" rel="toc">1.3. &rarr;1.3.</a></li>
21
+ </ul></li>
22
+ <li><a href="#bfheader-bd5a30e45e46b39eca67398f88312a1b" rel="toc">2. &rarr;2.</a>
23
+ <ul>
24
+ <li><a href="#bfheader-acbd18db4cc2f85cedef654fccc4a4d8" rel="toc">foo</a></li>
25
+ </ul></li>
26
+ </ul></li>
12
27
  </ul>
13
28
 
14
29
  <h1 id="bfheader-0cbc6611f5540bd0809a388dc95a615b">Test</h1>
@@ -19,26 +34,43 @@
19
34
 
20
35
  <p>aa &raquo; &laquo;</p>
21
36
 
22
- <ol>
23
- <li><p>&rarr;1.
24
- 2.% &rarr;1.1.
25
- 3.% &rarr;1.2.
26
- 4.%% &rarr;1.2.1.
27
- 5.%% &rarr;1.2.2.
28
- 6.% &rarr;1.3.
29
- abcdefg</p></li>
30
- <li><p>&rarr;2.
31
- abccccc</p></li>
32
- </ol>
37
+ <h2 id="bfheader-f2b20ed74117a2bda0525514a898e0e0">1. &rarr;1.</h2>
38
+
39
+ <h3 id="bfheader-4e7b97bf9819709771ba6c716991e3ef">1.1. &rarr;1.1.</h3>
40
+
41
+ <h3 id="bfheader-a4940c538c7be252daf50cc4237617ce">1.2. &rarr;1.2.</h3>
42
+
43
+ <h4 id="bfheader-b162ec5d01c9e20e3551a5b96fa9f650">1.2.1. &rarr;1.2.1.</h4>
44
+
45
+ <h4 id="bfheader-584eba1c1d454adaca0318b151a2dcb2">1.2.2. &rarr;1.2.2.</h4>
33
46
 
34
- <div style="border:2px solid gray ;width:300px;line-height:100%;border-radius:10px;">
47
+ <h3 id="bfheader-9868f67e1aa2e9e7d90a9a4846b8558f">1.3. &rarr;1.3.</h3>
48
+
49
+ <p>abcdefg</p>
50
+
51
+ <h2 id="bfheader-bd5a30e45e46b39eca67398f88312a1b">2. &rarr;2.</h2>
52
+
53
+ <p>abccccc</p>
54
+
55
+ <div style="border:2px solid gray ;width:300px;line-height:100%;border-radius:rad=10px;">
35
56
 
36
57
  <h3 id="bfheader-acbd18db4cc2f85cedef654fccc4a4d8">foo</h3>
37
58
 
38
- <p>bar<br />
59
+ <p>barasdf
60
+ <br />
61
+ <div style="border:2px solid gray ;width:200px;line-height:100%;border-radius:rad=10px;">
62
+ aaaaaa
63
+ cccc
64
+ <div style="border:2px solid gray ;width:100px;line-height:100%;border-radius:rad=10px;">
65
+ bbbbbb
66
+ </div>
67
+ </div>
68
+ <div style="border:2px solid gray ;width:200px;line-height:100%;border-radius:rad=10px;">
69
+ aaaaaa
70
+ </div>
71
+ <br />
72
+ <br />
39
73
  </div>
40
-
41
- <p><font color="#ff0000" face="" size="5">foo</font></p>
42
74
 
43
75
  </body>
44
76
  </html>
data/test/Test.md CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ {nrange:h2-h5}
2
2
  {toc:h1-h6}
3
3
 
4
4
  Test
@@ -28,10 +28,24 @@ abcdefg
28
28
  abccccc
29
29
 
30
30
  |-:b=2 solid gray w=300 rad=10-----------------|
31
- |### foo |
32
- |bar |
33
- |----------------------------------------------|
31
+ ### foo
32
+ bar
33
+ asdf
34
+
35
+ |-:b=2 solid gray w=200 rad=10-----------------|
36
+ aaaaaa
37
+ cccc
38
+ |-:b=2 solid gray w=100 rad=10-----------------|
39
+ bbbbbb
40
+ |____________________________________|
41
+ |__________________________________________|
42
+ kkkkkk
43
+ |-:b=2 solid gray w=200 rad=10-----------------|
44
+ aaaaaa
45
+ |__________________________________________|
46
+
34
47
 
48
+ |__________________________________________|
35
49
  *[foo](#ff0000/5)
36
50
 
37
51
 
data/test/test2.html ADDED
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <title>Test</title>
6
+ </head>
7
+ <body>
8
+
9
+ <h1 id="bfheader-0cbc6611f5540bd0809a388dc95a615b">Test</h1>
10
+
11
+ <h1 id="bfheader-afbc53b5508660ebc55ef0e9f6b92fc4">1. aaa</h1>
12
+
13
+ <h2 id="bfheader-5de9e1fcd9cd2972a7eb946c7bf542c6">1.1. abc</h2>
14
+
15
+ <h3 id="bfheader-27b4fea764f25be818fbddc9644dacda">1.1.1. kkkk</h3>
16
+
17
+ <h4 id="bfheader-9a36ccc535c67e888612b6c40b377ac0">1.1.1.1. www</h4>
18
+
19
+ <h1 id="bfheader-7ce41b8fd4205ac8204851ebda7996cc">2. qqq</h1>
20
+
21
+ <h2 id="bfheader-76627366ec5ded7ed3f5dd8bffbab2a0">2.1. rrr</h2>
22
+
23
+ <p>cccc</p>
24
+
25
+ <h3 id="bfheader-a87f63d7e810f249c861814cea02f2af">2.1.1. rtttt</h3>
26
+
27
+ <p>aaaa</p>
28
+
29
+ </body>
30
+ </html>
data/test/test2.md CHANGED
@@ -1,3 +1,27 @@
1
+ {nrange:H1-h5}
1
2
 
2
3
  Test
3
4
  ===
5
+
6
+ % aaa
7
+
8
+ %% abc
9
+
10
+ %%% kkkk
11
+
12
+ %%%% www
13
+
14
+ % qqq
15
+
16
+ %% rrr
17
+ cccc
18
+
19
+ %%% rtttt
20
+ aaaa
21
+
22
+
23
+
24
+
25
+
26
+
27
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: AoBane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-26 00:00:00.000000000 Z
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: math_ml
@@ -69,6 +69,9 @@ extra_rdoc_files: []
69
69
  files:
70
70
  - .gitignore
71
71
  - AoBane.gemspec
72
+ - AoBane.icns
73
+ - AoBane.jpg
74
+ - AoBane.tiff
72
75
  - Gemfile
73
76
  - LICENSE.txt
74
77
  - README.md
@@ -81,6 +84,7 @@ files:
81
84
  - lib/AoBane/version.rb
82
85
  - test/Test.html
83
86
  - test/Test.md
87
+ - test/test2.html
84
88
  - test/test2.md
85
89
  homepage: https://github.com/setminami/AoBane
86
90
  licenses:
@@ -110,4 +114,5 @@ summary: You can generate complex HTML with simple way.
110
114
  test_files:
111
115
  - test/Test.html
112
116
  - test/Test.md
117
+ - test/test2.html
113
118
  - test/test2.md