From aa06692c5bc575539760b436536edff626537bac Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 15 Oct 2011 13:59:07 -0400 Subject: v3: odf:odt, make odt style names more easily recognizable --- data/doc/sisu/CHANGELOG_v3 | 1 + lib/sisu/v3/odf.rb | 90 +++++++++++++++++++++++----------------------- lib/sisu/v3/odf_format.rb | 32 ++++++++--------- 3 files changed, 62 insertions(+), 61 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index ba08ca73..e8d609e9 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -24,6 +24,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.1.1.orig.tar.xz * odf:odt v1.0 * make odt header changes easier to track * get rid of (binary changeset) blob + * make odt style names more easily recognizable * manifest, odt url lnk, fix diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index e268b873..3bd59e81 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -158,8 +158,8 @@ module SiSU_ODF url=@md.fnb fn=@md.fn[:manifest] manifest="#{@env.url.root}/#{@md.fnb}/#{@md.fn[:manifest]}" - @@odf[:tail] << %{Available document outputs:
<#{manifest}>
} - @@odf[:tail] << %{\nSiSU: <www.jus.uio.no/sisu> and <www.sisudoc.org>} + @@odf[:tail] << %{Available document outputs:
<#{manifest}>
} + @@odf[:tail] << %{\nSiSU: <www.jus.uio.no/sisu> and <www.sisudoc.org>} @@odf[:tail] << "\n" end def heading(dob,p_num='') @@ -175,12 +175,12 @@ module SiSU_ODF unless @@docstart breakpage=if (@md.pagenew or @md.pagebreak) \ and (@md.pagenew =~ m or @md.pagebreak =~m) - ' ' + ' ' else '' end end @@docstart=false - dob.obj=%{#{breakpage}#{dob.obj}#{p_num}} + dob.obj=%{#{breakpage}#{dob.obj}#{p_num}} dob end def image_src(i) @@ -222,7 +222,7 @@ module SiSU_ODF and w.to_s =~/\d/ @@img_count +=1 %{#{c}} #anchor-type: as-char or paragraph or char or ... - else %{[image omitted]} + else %{[image omitted]} end end def image(dob) @@ -310,12 +310,12 @@ module SiSU_ODF dob.obj= if dob.is=='para' \ and dob.indent.to_s =~/[0-9]/ \ and dob.indent == dob.hang - %{#{dob.obj}#{p_num}} + %{#{dob.obj}#{p_num}} elsif dob.is=='para' \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang # NOT yet implemented - %{#{dob.obj}#{p_num}} - else %{#{dob.obj}#{p_num}} + %{#{dob.obj}#{p_num}} + else %{#{dob.obj}#{p_num}} end dob end @@ -372,7 +372,7 @@ module SiSU_ODF def group_clean(str) str.gsub!(/&nbsp;| |#{Mx[:nbsp]}/,' ') str.gsub!(//,'>') - str.gsub!(/<(text:span text:style-name="T[1-5]"|\/text:span)>/,'<\1>') #works, not ideal + str.gsub!(/<(text:span text:style-name="Table_\S+?"|\/text:span)>/,'<\1>') #works, not ideal str.gsub!(/#{Mx[:br_line]}/,'
') str.gsub!(/<br(?:\s+\/)?>/,'
') str @@ -381,10 +381,10 @@ module SiSU_ODF parray=[] dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num}} \ + '' dob end @@ -404,10 +404,10 @@ module SiSU_ODF parablock.gsub!(/<(text:p text:style-name="Footnote")>/,'<\1>') parablock.gsub!(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') parablock=footnote(parablock) - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num}} \ + '' dob end @@ -427,10 +427,10 @@ module SiSU_ODF parablock.gsub!(/<(text:p text:style-name="Footnote")>/,'<\1>') parablock.gsub!(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') parablock=footnote(parablock) - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num}} \ + '' dob end @@ -443,10 +443,10 @@ module SiSU_ODF parablock.gsub!(/^\s*$/,'
') parablock.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '\1') #http ftp matches escaped, no decoration - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num}} \ + '' end dob @@ -570,17 +570,17 @@ module SiSU_ODF dob.obj.gsub!(/©/,'©') #too arbitrary dob.obj.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, - '\1') + '\1') dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - '\1') + '\1') dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - '\1') + '\1') dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - '\1') + '\1') dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - '\1') + '\1') dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - '\1') + '\1') dob.obj.gsub!(/­/u,'-') dob.obj.gsub!(/ /u, ' ') # space identify dob.obj.gsub!(/ /u, ' ') # space identify @@ -653,33 +653,33 @@ WOK #{table} - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index 7a9b267d..5abf5090 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -65,7 +65,7 @@ module SiSU_ODF_format @paranum=/(\d+)/m.match(paranum.to_s)[1] end def display - @paranum.gsub(/(\d+)/,' [\1]') + @paranum.gsub(/(\d+)/,' [\1]') end def name @paranum.gsub(/(\d+)/,'') @@ -142,13 +142,13 @@ module SiSU_ODF_format end def table_close(tablefoot='') '' \ - + %{#{@p_num}} + + %{#{@p_num}} end def table_tag_cell(str,i) txt_name_cell=if i==0 \ and @dob.head_ - 'Table_20_Heading' - else 'P7' + 'Table_Heading' + else 'P_table_cell' end str.gsub!(/^~$/,'') # tilde / empty cell %{#{@br}} + @@ -165,8 +165,8 @@ module SiSU_ODF_format def table_tag_row_dump(str,i) txt_name_row=if i==0 \ and @dob.head_ - 'Table_20_Heading' - else 'P7' + 'Table_Heading' + else 'P_table_cell' end %{#{@br}} + %{#{@br}} + @@ -353,29 +353,29 @@ WOK - + - + - + - + - + - + - + - + @@ -455,12 +455,12 @@ WOK @md,@t_o=md,t_o end def br_page - @t_o.obj=' ' + @t_o.obj=' ' @t_o end def obj_sep #center later sep='--- ' - @t_o.obj=%{#{sep*20}} + @t_o.obj=%{#{sep*20}} @t_o end end -- cgit v1.2.3