From f31e286f4a73c5c0f355512b0cb45c6c82088516 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 22 Jun 2013 01:13:46 -0400 Subject: v5: general code cleaning * propagate back to v4 after testing --- lib/sisu/v5/dal_doc_str.rb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib/sisu/v5/dal_doc_str.rb') diff --git a/lib/sisu/v5/dal_doc_str.rb b/lib/sisu/v5/dal_doc_str.rb index 2979412b..971f9f67 100644 --- a/lib/sisu/v5/dal_doc_str.rb +++ b/lib/sisu/v5/dal_doc_str.rb @@ -78,7 +78,7 @@ module SiSU_DAL_DocumentStructureExtract @pbl=SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) end def ln_get(lv) - ln=case lv + case lv when /A/; 1 when /B/; 2 when /C/; 3 @@ -91,10 +91,14 @@ module SiSU_DAL_DocumentStructureExtract end end def image_test(str) - boolean=(str=~/\{\s*\S+?\.png.+?\}https?:\/\/\S+/ ? true : false) + str=~/\{\s*\S+?\.png.+?\}https?:\/\/\S+/ \ + ? true + : false end def bullet_test(str) - bool=((str=~/\*/) ? true : false) + (str=~/\*/) \ + ? true + : false end def hang_and_indent_test(str) hang_indent=if str=~/^_([1-9])[^_]/ @@ -128,7 +132,9 @@ module SiSU_DAL_DocumentStructureExtract [hang,indent,obj] end def endnote_test?(str) - bool=((str=~/~\{.+?\}~|~\[.+?\]~/) ? true : false) + (str=~/~\{.+?\}~|~\[.+?\]~/) \ + ? true + : false end def extract_tags(str,nametag=nil) tags=[] @@ -146,7 +152,6 @@ module SiSU_DAL_DocumentStructureExtract [str,tags] end def identify_parts - data=@data tuned_file=[] @tuned_block,@tuned_code=[],[] @@counter,@verse_count=0,0 @@ -365,7 +370,6 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - t_o h={ obj: 'table end' } #introduce a counter t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) t_o @@ -448,7 +452,7 @@ module SiSU_DAL_DocumentStructureExtract and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ # fix logic sub_array=t_o.dup @line_mode=sub_array.scan(/.+/) - type=if @@flag['poem']; 'poem' + type='poem' if @@flag['poem'] t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join poem=t_o.split(/\n\n/) poem.each do |v| @@ -458,10 +462,9 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end - else 'group' - end - @verse_count+=1 if @@flag['poem'] + else 'group' end + @verse_count+=1 if @@flag['poem'] end if not @@flag['code'] if @@flag['poem'] \ @@ -507,7 +510,6 @@ module SiSU_DAL_DocumentStructureExtract tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ ln: 4, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) - tuned_file h={ obj: 'eof' } meta=SiSU_DAL_DocumentStructure::ObjectMetadata.new.metadata(@metadata) [tuned_file,meta] @@ -597,8 +599,7 @@ module SiSU_DAL_DocumentStructureExtract def ocn #and auto segment numbering increment data=@data @o_array=[] - node=ocn=ocn_dv=ocn_sp=ocnh=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnm=ocnu=ocnk=nm=0 # h heading, o other, t table, g group, i image - node_count_flag=false + node=ocn=ocn_dv=ocn_sp=ocnh=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image regex_exclude_ocn_and_node = /#{Rx[:meta]}|^@\S+?:\s|^4~endnotes|^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^\^~ |<:e[:_]\d+?>|^<:\#|<:- |<[:!]!4|