AoBane 0.1.5 → 0.1.6
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/lib/AoBane/utilities.rb +1 -1
- data/lib/AoBane/version.rb +1 -1
- data/lib/AoBane.rb +82 -78
- metadata +1 -1
data/lib/AoBane/utilities.rb
CHANGED
@@ -52,7 +52,7 @@ def postPaling(text)
|
|
52
52
|
output = text.split("\n")
|
53
53
|
output.each_with_index{|line,index|
|
54
54
|
if /#{$startDivMark}/ =~ line then
|
55
|
-
output[index] = '<div style="border:' + $1 + 'px ' + $2 + ';' +
|
55
|
+
output[index] = '<div style="line-height:50%;border:' + $1 + 'px ' + $2 + ';' +
|
56
56
|
if $4.nil? then '' else 'width:' + if Utilities::isDigit($4) then $4 + 'px;' else $4 + ';' end end +
|
57
57
|
if $6.nil? then '' else 'height:' + if Utilities::isDigit($6) then $6 + 'px;' else $6 + ';' end end +
|
58
58
|
if $8.nil? then '' else 'background-color:' + $8 + ';' end +
|
data/lib/AoBane/version.rb
CHANGED
data/lib/AoBane.rb
CHANGED
@@ -51,8 +51,8 @@ require 'AoBane/utilities'
|
|
51
51
|
require 'math_ml/string'
|
52
52
|
|
53
53
|
module AoBane
|
54
|
-
VERSION = '0.1.
|
55
|
-
VERSION_NUMBER = 0.
|
54
|
+
VERSION = '0.1.6'
|
55
|
+
VERSION_NUMBER = 0.0106
|
56
56
|
RELEASE_DATE = '2013-04-15'
|
57
57
|
VERSION_LABEL = "#{VERSION} (#{RELEASE_DATE})"
|
58
58
|
|
@@ -503,89 +503,93 @@ module AoBane
|
|
503
503
|
### it. The parameter is for compatibility with RedCloth, and is currently
|
504
504
|
### unused, though that may change in the future.
|
505
505
|
def parse_text(source, rs = nil)
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
506
|
+
rs ||= RenderState.new
|
507
|
+
|
508
|
+
# check
|
509
|
+
case rs.header_id_type
|
510
510
|
when HeaderIDType::MD5, HeaderIDType::ESCAPE
|
511
511
|
else
|
512
|
-
|
512
|
+
rs.warnings << "illegal header id type - #{rs.header_id_type}"
|
513
513
|
end
|
514
|
+
|
515
|
+
# Create a StringScanner we can reuse for various lexing tasks
|
516
|
+
@scanner = StringScanner::new( '' )
|
517
|
+
|
518
|
+
# Make a copy of the string with normalized line endings, tabs turned to
|
519
|
+
# spaces, and a couple of guaranteed newlines at the end
|
520
|
+
|
521
|
+
text = detab(source.gsub( /\r\n?/, "\n" ))
|
522
|
+
text += "\n\n"
|
523
|
+
@log.debug "Normalized line-endings: %p" % text
|
524
|
+
|
525
|
+
#Insert by set.minami 2013-03-30
|
526
|
+
text.gsub!(/\*\[(.*?)\]\((.*?)(\|.*?)*(\/.*?)*\)/){|match|
|
527
|
+
'<font color="' +
|
528
|
+
if $2.nil? then '' else $2 end +'" ' +
|
529
|
+
'face="' +
|
530
|
+
if $3.nil? then '' else $3.delete('|') end + '" ' +
|
531
|
+
'size="' +
|
532
|
+
if $4.nil? then '' else $4.delete('/') end + '">' +
|
533
|
+
$1 + '</font>'
|
534
|
+
}
|
535
|
+
#Insert by set.minami 2013-04-13
|
536
|
+
text = Utilities::prePaling(text)
|
537
|
+
|
538
|
+
#Insert by set.minami 2013-04-01
|
539
|
+
text.gsub!(/\\TeX\{(.+?)\\TeX\}/){
|
540
|
+
begin
|
541
|
+
$1.to_mathml
|
542
|
+
rescue => e
|
543
|
+
puts 'math_ml Error: ' + $1
|
544
|
+
puts e
|
545
|
+
end
|
546
|
+
}
|
514
547
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
#Insert by set.minami 2013-04-13
|
536
|
-
text = Utilities::prePaling(text)
|
537
|
-
|
538
|
-
#Insert by set.minami 2013-04-03
|
539
|
-
nrange = []
|
540
|
-
departure = 1
|
541
|
-
preproc = Marshal.load(Marshal.dump(text))
|
542
|
-
text.clear
|
543
|
-
texParser = MathML::LaTeX::Parser.new
|
544
|
-
html_text_number = 0
|
545
|
-
preproc.lines { |line|
|
546
|
-
html_text_number += 1
|
547
|
-
begin
|
548
|
-
line.gsub!(/^\{nrange:(.*?)(;\d+){0,1}\}/){ |match|
|
549
|
-
depNum = $2.delete(';').to_i
|
550
|
-
departure =
|
551
|
-
if depNum > 0 then depNum else 1 end
|
552
|
-
if /[hH]([1-6])\-[hH]([1-6])/ =~ $1
|
553
|
-
nrange.push($1)
|
554
|
-
nrange.push($2)
|
555
|
-
if nrange.size > 2 then
|
556
|
-
nrange.pop
|
557
|
-
nrange.pop
|
558
|
-
raise "Syntax Error!"
|
559
|
-
end
|
560
|
-
end
|
561
|
-
next
|
562
|
-
}
|
563
|
-
#Insert by set.minami 2013-04-01
|
564
|
-
texTag = '\\\\TeX'
|
565
|
-
line.gsub!(/#{texTag}\{(.+?)#{texTag}\}/){
|
566
|
-
texParser.parse($1,false).to_s
|
567
|
-
}
|
568
|
-
@log.debug line
|
569
|
-
#calculate numbering
|
570
|
-
range = nrange[1].to_i - nrange[0].to_i
|
571
|
-
if range == 0 then range = 1 end
|
572
|
-
if range < 0 then
|
573
|
-
p "AoBane Syntax Error:Header range is WRONG!" +
|
574
|
-
"@ l.#{html_text_number}";exit(-1)
|
575
|
-
raise FatalError,"AoBane Syntax Error:Header range is WRONG!"
|
548
|
+
#Insert by set.minami 2013-04-03
|
549
|
+
nrange = []
|
550
|
+
departure = 1
|
551
|
+
preproc = Marshal.load(Marshal.dump(text))
|
552
|
+
text.clear
|
553
|
+
html_text_number = 0
|
554
|
+
preproc.lines { |line|
|
555
|
+
html_text_number += 1
|
556
|
+
begin
|
557
|
+
line.gsub!(/^\{nrange:(.*?)(;\d+){0,1}\}/){ |match|
|
558
|
+
depNum = $2.delete(';').to_i
|
559
|
+
departure =
|
560
|
+
if depNum > 0 then depNum else 1 end
|
561
|
+
if /[hH]([1-6])\-[hH]([1-6])/ =~ $1
|
562
|
+
nrange.push($1)
|
563
|
+
nrange.push($2)
|
564
|
+
if nrange.size > 2 then
|
565
|
+
nrange.pop
|
566
|
+
nrange.pop
|
567
|
+
raise "Syntax Error!"
|
576
568
|
end
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
569
|
+
end
|
570
|
+
next
|
571
|
+
}
|
572
|
+
@log.debug line
|
573
|
+
#calculate numbering
|
574
|
+
range = nrange[1].to_i - nrange[0].to_i
|
575
|
+
if range == 0 then range = 1 end
|
576
|
+
if range < 0 then
|
577
|
+
p "AoBane Syntax Error:Header range is WRONG!" +
|
578
|
+
"@ l.#{html_text_number}";exit(-1)
|
579
|
+
raise FatalError,"AoBane Syntax Error:Header range is WRONG!"
|
580
|
+
end
|
581
|
+
line.gsub!(/^(%{1,#{range}})(.*?)\n$/){ |match|
|
582
|
+
line = Utilities.
|
583
|
+
calcSectionNo(nrange.min,range,$1.size,departure,$2)
|
584
|
+
}
|
585
|
+
text << line
|
586
|
+
@log.debug nrange.minmax
|
583
587
|
rescue => e
|
584
|
-
|
585
|
-
|
586
|
-
|
588
|
+
@log.warn "AoBane Syntax WARNING l.#{html_text_number}:#{line.chomp} haven't adopted"
|
589
|
+
@log.warn e
|
590
|
+
end
|
587
591
|
}
|
588
|
-
|
592
|
+
|
589
593
|
#Insert by set.minami
|
590
594
|
|
591
595
|
# Filter HTML if we're asked to do so
|