diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-01-23 21:42:25 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-01-23 21:42:27 -0500 |
commit | 21f5e220b738add01c19c2b15a76f2d240b2c0d5 (patch) | |
tree | 287dac6e47cab1da0d0567e9dc79683bc8d757b0 /lib/sisu/v3dv/epub_format.rb | |
parent | v3dv: call most methods by full name (include associated module & class names) (diff) |
v3dv: replace use of most ruby exclamation (!) method actionssisu_3.1.12
Diffstat (limited to 'lib/sisu/v3dv/epub_format.rb')
-rw-r--r-- | lib/sisu/v3dv/epub_format.rb | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/lib/sisu/v3dv/epub_format.rb b/lib/sisu/v3dv/epub_format.rb index 3f7ea4d5..c1987fa0 100644 --- a/lib/sisu/v3dv/epub_format.rb +++ b/lib/sisu/v3dv/epub_format.rb @@ -1493,12 +1493,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.author.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="aut">#{x}</dc:creator>} else '' end @@ -1515,12 +1515,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.editor.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="edt">#{x}</dc:creator>} else '' end @@ -1537,12 +1537,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.translator.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="trl">#{x}</dc:creator>} else '' end @@ -1559,28 +1559,28 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.illustrator.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="ill">#{x}</dc:creator>} else '' end date_published=if defined? @md.date.published \ and @md.date.published =~/\S+/ x=@md.date.published.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:date opf:event="published">#{x}</dc:date>} else '' end subject=if defined? @md.classify.subject \ and @md.classify.subject =~/\S+/ x=@md.classify.subject.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:subject>#{x}</dc:subject>} else '' end @@ -2177,7 +2177,7 @@ WOK end end if @txt and not @txt.empty? - @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end @p_num=ParagraphNumber.new(@md,@ocn) @vz=SiSU_Env::GetInit.instance.skin @@ -2216,60 +2216,60 @@ WOK </div> } end - def para_form_css(tag,attrib) # regular paragraphs shaped here + def para_form_css(tag,attrib,txt) # regular paragraphs shaped here ul=ulc='' ul,ulc="<ul>\n ","\n </ul>" if @tag =~/li/ %{ <div class="substance"> #{@p_num.ocn_display} #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> - #{@named}#{@txt} + #{@named}#{txt} </#{tag}>#{ulc} </div> } end def para - para_form_css('p','norm') + para_form_css('p','norm',@txt) end def group - para_form_css('p','group') + para_form_css('p','group',@txt) end def block - para_form_css('p','block') + para_form_css('p','block',@txt) end def alt - para_form_css('p','alt') + para_form_css('p','alt',@txt) end def verse - para_form_css('p','verse') + para_form_css('p','verse',@txt) end def code - para_form_css('p','code') + para_form_css('p','code',@txt) end def center - para_form_css('p','center') + para_form_css('p','center',@txt) end def bold - para_form_css('p','bold') + para_form_css('p','bold',@txt) end def bullet - para_form_css('li','bullet') + para_form_css('li','bullet',@txt) end def table @txt=if @t_o.obj !~/^<table\s/ table=SiSU_XHTML_Shared::TableXHTML.new(@t_o) #move, make happen earlier - @txt=table.table.obj + table.table.obj else @txt end - para_form_css('p','norm') + para_form_css('p','norm',@txt) end def break - @txt.gsub!(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />') - @txt.gsub!(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') - para_form_css('p','norm') + @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />'). + gsub(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') + para_form_css('p','norm',@txt) end def format(tag,attrib) - para_form_css(tag,attrib) + para_form_css(tag,attrib,@txt) end def title_heading(tag,attrib) %{ @@ -2298,8 +2298,8 @@ WOK def title_heading4 '' end - def seg_heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + def seg_heading_sub(tag,attrib,txt) + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -2320,10 +2320,10 @@ WOK } end def seg_heading5 - seg_heading_sub('p','bold') + seg_heading_sub('p','bold',@txt) end def seg_heading6 - seg_heading_sub('p','bold') + seg_heading_sub('p','bold',@txt) end def dl #check :trailer "<dl><b>#{@txt}</b> #{@trailer}</dl>" @@ -2333,18 +2333,19 @@ WOK </p> </div>' end - def gsub_body - case @txt + def gsub_body #unused + @txt=case @txt when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') + @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'<b>\1</b>') + @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'<b>\1</b>') + @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>') + else @txt end end def bold_para @@ -2356,9 +2357,9 @@ WOK #{@vz.table_close}} end - def bold_heading - @txt.gsub!(/[1-9]~\S+/,'') - @txt.gsub!(/[1-9]~/,'') + def bold_heading #unused + @txt=@txt.gsub(/[1-9]~\S+/,''). + gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> @@ -2444,9 +2445,8 @@ WOK } end def clean(txt) - txt.gsub!(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'') - txt.gsub!(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') - txt + txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,''). + gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') end def subtoc_lev(tag,attrib) @txt=clean(@txt) @@ -2458,10 +2458,10 @@ WOK note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end note=$1 - note.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/<a[\n\s]+"[\n\s]+href="#note_ref\d+"> <sup id="note\d+">\d+<\/sup> /m,'') - txt.gsub!(/<a[\n\s]+"[\n\s]+href="#note_ref\d+">#{Mx[:nbsp]}<sup id="note\d+">\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove + note=note.gsub(/[\n\s]+/m,' ') + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). + gsub(/<a[\n\s]+"[\n\s]+href="#note_ref\d+"> <sup id="note\d+">\d+<\/sup> /m,''). + gsub(/<a[\n\s]+"[\n\s]+href="#note_ref\d+">#{Mx[:nbsp]}<sup id="note\d+">\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove end %{<#{tag} class="#{attrib}"> <a href="#o#{@ocn}"><i>#{txt}</i></a> #{note} @@ -2473,8 +2473,8 @@ WOK def subtoc_lev6 subtoc_lev('h6','subtoc') if @txt end - def heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + def heading_sub(tag,attrib,txt) + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -2496,10 +2496,10 @@ WOK } end def heading5 - heading_sub('p','bold') + heading_sub('p','bold',@txt) end def heading6 - heading_sub('p','bold') + heading_sub('p','bold',@txt) end def navigation_heading4 %{<table summary="navigation segment heading 4" width=100% bgcolor="#08163f" border="0"> |