aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/digests.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-06-22 01:13:46 -0400
committerRalph Amissah <ralph@amissah.com>2013-06-22 01:13:49 -0400
commitf31e286f4a73c5c0f355512b0cb45c6c82088516 (patch)
treefdf22b179aef9937e7f6a3e71fc6c1e7f0ff9119 /lib/sisu/v5/digests.rb
parentvim, ftplugin sisu.vim, c-\ hard wrap lines to line width (moved from c-j) (diff)
v5: general code cleaningsisu_4.1.5
* propagate back to v4 after testing
Diffstat (limited to 'lib/sisu/v5/digests.rb')
-rw-r--r--lib/sisu/v5/digests.rb42
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb
index 902a0e94..9eba6544 100644
--- a/lib/sisu/v5/digests.rb
+++ b/lib/sisu/v5/digests.rb
@@ -63,7 +63,6 @@ module SiSU_DigestView
require_relative 'particulars' # particulars.rb
require_relative 'prog_text_translation' # prog_text_translation.rb
require_relative 'shared_markup_alt.rb' # shared_markup_alt.rb
- pwd=Dir.pwd
class Source
@@dg=nil
def initialize(opt)
@@ -149,14 +148,13 @@ module SiSU_DigestView
def message_digest
data=@data
sys=SiSU_Env::SystemCall.new
- l=Hash.new(0)
@p=[]
@g,@v,@r='','',''
data.each do |para|
x=nil
y,para_endnotes=[],[]
- if para =~/#{Mx[:id_o]}~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)#{Mx[:id_c]}#{Mx[:id_o]}([0-9a-f]{#{@dl}}):([0-9a-f]{#{@dl}})#{Mx[:id_c]}/
- ocn,h1,h2,d_clean,d_all=$1,$2,$3,$4,$5
+ if para =~/#{Mx[:id_o]}~(\d+);(?:(?:\w|[0-6]:)\d+);(?:\w\d+)#{Mx[:id_c]}#{Mx[:id_o]}([0-9a-f]{#{@dl}}):([0-9a-f]{#{@dl}})#{Mx[:id_c]}/
+ ocn,d_clean,d_all=$1,$2,$3
@ocn=ocn unless ocn.to_i==0
para=para.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
@@ -164,29 +162,29 @@ module SiSU_DigestView
if para=~/#{Mx[:en_a_o]}[\d*+]+.+?#{Mx[:id_o]}[0-9a-f]{#{@dl}}#{Mx[:id_c]}#{Mx[:en_a_c]}/
para_endnotes << para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+).+?#{Mx[:id_o]}([0-9a-f]{#{@dl}})#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/)
end
- ima=[]
+ images=[]
if para !~/^%+\s/ \
and para =~/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
images=para.scan(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/).flatten
- else image=nil
+ else nil
end
x=case para
when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/
- "\n" + ' '*0 +'@' + ' '*9
+ "\n" << ' '*0 << '@' << ' '*9
when /^#{Mx[:meta_o]}subtitle#{Mx[:meta_c]}/
- "\n" + ' '*1 +'@' + ' '*8
+ "\n" << ' '*1 << '@' << ' '*8
when /^#{Mx[:lv_o]}1:/ #fix Mx[:lv_o]
- "\n" + ' '*2 +':A ' + ' '*6 +'- ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all
+ "\n" << ' '*2 << ':A ' << ' '*6 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all
when /^#{Mx[:lv_o]}2:/ #fix Mx[:lv_o]
- "\n" + ' '*3 +':B ' + ' '*5 +'- ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all
+ "\n" << ' '*3 << ':B ' << ' '*5 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all
when /^#{Mx[:lv_o]}3:/ #fix Mx[:lv_o]
- "\n" + ' '*4 +':C ' + ' '*4 +'- ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all
+ "\n" << ' '*4 << ':C ' << ' '*4 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all
when /^#{Mx[:lv_o]}4:/ #fix Mx[:lv_o]
- "\n" + ' '*5 +'1' + ' '*4 +'- ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all
+ "\n" << ' '*5 << '1' << ' '*4 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all
when /^#{Mx[:lv_o]}5:/ #fix Mx[:lv_o]
- "\n" + ' '*6 +'2' + ' '*3 +'- ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all
+ "\n" << ' '*6 << '2' << ' '*3 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all
when /^#{Mx[:lv_o]}6:/ #fix Mx[:lv_o]
- "\n" + ' '*7 +'3' + ' '*2 +'- ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all
+ "\n" << ' '*7 << '3' << ' '*2 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all
else
if para =~/MD5\(\S+?\.sst\)=\s*<u>([0-9a-f]{#{@dl}})<\/u>/ #watch
@n,@s=/MD5\((\S+?\.sst)\)=\s*<u>([0-9a-f]{#{@dl}})<\/u>/.match(para)[1,2]
@@ -259,7 +257,7 @@ module SiSU_DigestView
when /#{m_author}: /
@c=/#{m_author}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip
when /#{m_sourcefile_digest}.+?<u>/ #watch
- dgst_extra="\n" + ' '*21 +'source' +' '*4 + @md.dgst[1] + ' '*34 + @md.fns
+ dgst_extra="\n" << ' '*21 << 'source' << ' '*4 << @md.dgst[1] << ' '*34 << @md.fns
when /#{m_sisu_version}: /
@v=/#{m_sisu_version}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip
when /#{m_last_generated}: /
@@ -268,7 +266,7 @@ module SiSU_DigestView
@r=/#{m_ruby_version}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip
end
dgst_extra ||=''
- "\n" + prefix +' - ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all + dgst_extra + "\n"
+ "\n" << prefix << ' - ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all << dgst_extra << "\n"
end
end
para_endnotes[0].each { |e| y << "\n" + ' '*(28-e[0].length) + "[#{e[0].to_s}] #{e[1].to_s}" } if para_endnotes[0]
@@ -331,17 +329,17 @@ module SiSU_DigestView
if t_o.is==:heading
x=case t_o.ln
when 1; l[1] +=1 #fix Mx[:lv_o]
- ' '*0 +':A'
+ ' '*0 << ':A'
when 2; l[2] +=1 #fix Mx[:lv_o]
- ' '*1 +':B'
+ ' '*1 << ':B'
when 3; l[3] +=1 #fix Mx[:lv_o]
- ' '*2 +':C'
+ ' '*2 << ':C'
when 4; l[4] +=1 #fix Mx[:lv_o]
- ' '*3 +'1'
+ ' '*3 << '1'
when 5; l[5] +=1 #fix Mx[:lv_o]
- ' '*4 +'2'
+ ' '*4 << '2'
when 6; l[6] +=1 #fix Mx[:lv_o]
- ' '*5 +'3'
+ ' '*5 << '3'
else nil
end
end