From 2d9e5eca8ebd1dbe8ce3158588c69bd2d3f8750e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 21 Nov 2011 00:13:47 -0500 Subject: v3: odf:odt v1.2 * includes previously unimplemented hanging indents * done: dal, plaintext, html, epub, xhtml, xml (sax & dom), odt, pdf, sql; not done: man, info --- lib/sisu/v3/odf.rb | 64 +++----- lib/sisu/v3/odf_format.rb | 397 +++++++++++++++++++++++++++++++--------------- 2 files changed, 287 insertions(+), 174 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 5a095ba9..b7b747ee 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -178,7 +178,7 @@ module SiSU_ODF end end @@docstart=false - dob.obj=%{#{breakpage}#{dob.obj}#{p_num}} + dob.obj=%{#{breakpage}#{dob.obj}#{p_num}} dob end def image_src(i) @@ -311,8 +311,8 @@ module SiSU_ODF %{#{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}} + and dob.indent != dob.hang + %{#{dob.obj}#{p_num}} else %{#{dob.obj}#{p_num}} end dob @@ -370,7 +370,7 @@ module SiSU_ODF def group_clean(str) str.gsub!(/&nbsp;| |#{Mx[:nbsp]}/,' ') str.gsub!(//,'>') - str.gsub!(/<(text:span text:style-name="Table_\S+?"|\/text:span)>/,'<\1>') #works, not ideal + str.gsub!(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>') #works, not ideal str.gsub!(/#{Mx[:br_line]}/,'
') str.gsub!(/<br(?:\s+\/)?>/,'
') str @@ -568,17 +568,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 @@ -647,43 +647,15 @@ WOK end x=< - - + + #{table} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + WOK x.strip! @@ -712,10 +684,14 @@ WOK def odf #%odf output env=SiSU_Env::SiSU_file.new(@md) env.mkdir - header=SiSU_ODF_format::ODT_head_1_0.new(@md) + header=SiSU_ODF_format::ODT_head_1_2.new(@md) + filename="#{@env.processing_path.odt}/manifest.rdf" + od=File.new(filename,'w+') + od << header.manifest_rdf + od.close filename="#{@env.processing_path.odt}/META-INF/manifest.xml" od=File.new(filename,'w+') - od << header.meta_inf_manifest_xml + od << header.meta_inf_manifest_xml(@md) od.close filename="#{@env.processing_path.odt}/meta.xml" od=File.new(filename,'w+') diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index 5abf5090..5ffe458e 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+)/,'') @@ -200,25 +200,60 @@ module SiSU_ODF_format @dob end end - class ODT_head_1_0 + class ODT_head_1_2 def initialize(md) @md=md @generator="#{@md.sisu_version[:project]} #{@md.sisu_version[:version]} #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" end - def meta_inf_manifest_xml + def manifest_rdf + x=< + + + + + + + + + + + + + + + + + +WOK + x.strip! + x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x + end + def meta_inf_manifest_xml(md) + images=[' '] + if md.ec[:image].length > 0 + md.ec[:image].each do |i| + images<<< +WOK + end + end + images=images.join('') x=< - - - - - - + + + + #{images} - - + + + + + WOK x.strip! @@ -228,7 +263,7 @@ WOK def meta_xml x=< - + #{@generator} #{@md.generated} @@ -244,77 +279,98 @@ WOK def settings_xml x=< - + 0 0 - 21459 - 22068 + 0 + 0 true false view2 - 3002 - 11008 + 0 + 0 0 0 - 21458 - 22066 + 0 + 0 0 + 2 + true 100 false - true - false - 1 - false + true + false + false + true + true + false + true + false + false + + false + false + false + true + true 0 - false - false + false + false + false + false + true + false + false + false + false + true + true false false - true - - true - true - true - - 0 - false true + false true + false + high-resolution + 1 + 0 + true + + + false + true + + false + true + false true - true + false + true false - false - false - true - - - false - true - false - false - true - false - false + true + true + false true + true true + false + false + + false 0 - false - false - high-resolution - false - true - - true - false + false + false + true + true @@ -326,9 +382,9 @@ WOK def styles_xml x=< - + - + @@ -336,15 +392,15 @@ WOK - + - + - + @@ -353,89 +409,170 @@ WOK - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + - + - + WOK -- cgit v1.2.3