aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/odf.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-10-15 19:27:16 +0100
committerRalph Amissah <ralph@amissah.com>2007-10-15 19:27:16 +0100
commite1ec4bd2dad2bd22ad97cea398ae1cfcfae183a2 (patch)
tree6ffe3ae1b2453578a032ce053934a31f980645e9 /lib/sisu/v0/odf.rb
parentregex matching of images, (and rearrangement of conditionals) (diff)
mostly the arrangement of conditionals
Diffstat (limited to 'lib/sisu/v0/odf.rb')
-rw-r--r--lib/sisu/v0/odf.rb37
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb
index feea7cde..78099d16 100644
--- a/lib/sisu/v0/odf.rb
+++ b/lib/sisu/v0/odf.rb
@@ -211,12 +211,16 @@ module SiSU_ODF
para.gsub!(/^([1-6])~\S*\s/,'')
m=/#{$1}/
breakpage=''
- if @md.fns and @md.fns != '' and @md.fns !=@@fns
+ if @md.fns \
+ and @md.fns != '' \
+ and @md.fns !=@@fns
@@docstart=true
@@fns=@md.fns
end
unless @@docstart
- breakpage=if (@md.pagenew or @md.pagebreak) and (@md.pagenew =~ m or @md.pagebreak =~m); '<text:p text:style-name="P9"> </text:p>'
+ breakpage=if (@md.pagenew or @md.pagebreak) \
+ and (@md.pagenew =~ m or @md.pagebreak =~m)
+ '<text:p text:style-name="P9"> </text:p>'
else ''
end
end
@@ -224,9 +228,11 @@ module SiSU_ODF
%{#{breakpage}<text:h text:style-name="Heading_20_#{no}" text:outline-level="#{no}">#{para}</text:h>}
end
def image_src(i)
- image_source=if @md.fns =~/\.ss[tm]$/ and FileTest.file?("#{@env.path.image_source_local_tex}/#{i}") #review
+ image_source=if @md.fns =~/\.ss[tm]$/ \
+ and FileTest.file?("#{@env.path.image_source_local_tex}/#{i}") #review
@env.path.image_source_local_tex
- elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{@env.path.image_source_remote_tex}/#{i}")
+ elsif @md.fns =~/\.-ss[tm]$/ \
+ and FileTest.file?("#{@env.path.image_source_remote_tex}/#{i}")
@env.path.image_source_remote_tex
elsif FileTest.file?("#{@env.path.image_source_tex}/#{i}")
@env.path.image_source_tex
@@ -251,7 +257,9 @@ module SiSU_ODF
image_source=image_src(i)
pwd=Dir.pwd
cp("#{image_source}/#{i}","#{@env.path.odf}/Pictures/#{i}") if image_source
- img=if i.to_s =~/jpg|png|gif/ and h.to_s =~/\d/ and w.to_s =~/\d/
+ img=if i.to_s =~/jpg|png|gif/ \
+ and h.to_s =~/\d/ \
+ and w.to_s =~/\d/
@@img_count +=1
%{<draw:frame draw:style-name="fr1" draw:name="graphics#{@@img_count}" text:anchor-type="as-char" svg:width="#{w}cm" svg:height="#{h}cm" draw:z-index="2"><draw:image xlink:href="Pictures/#{i}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>#{c}} #anchor-type: as-char or paragraph or char or ...
else %{<text:p text:style-name="P1">[image omitted]</text:p>}
@@ -465,7 +473,9 @@ module SiSU_ODF
word.each do |w| # _ - / # | : ! ^ ~
unless para =~/^(?:0~|%+ )/m
w.gsub!(/&#(?:126|152);/,'~') #126 usual
- if w !~/&\S{1,7};/ or w =~/&nbsp;/; w.gsub!(/&/,'&amp;') #watch &nbsp;
+ if w !~/&\S{1,7};/ \
+ or w =~/&nbsp;/
+ w.gsub!(/&/,'&amp;') #watch &nbsp;
end
end
para_array << w
@@ -522,7 +532,8 @@ module SiSU_ODF
if d_meta; odf_metadata(d_meta)
end
end
- @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/1~meta\s+Document Information/)
+ @rcdc=true if @rcdc==false \
+ and (para =~/~metadata/ or para =~/1~meta\s+Document Information/)
if para !~/(^0~|<ENDNOTES>|<EOF>)/
if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change
paranum=para[@regx,3]
@@ -533,7 +544,8 @@ module SiSU_ODF
### problem in scroll, it appears tables are getting paragraph numbers
unless @rcdc
m=/<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/
- if para =~m and para=~/\S+/
+ if para =~m \
+ and para=~/\S+/
para=case @sto.format
when /^(1)~(?:(\S+))?/; odf_structure(para,$1,@sto.ocn,$2)
para
@@ -576,7 +588,10 @@ module SiSU_ODF
format_text=OD_format::Format_text_object.new(one,two)
para=format_text.seg_no_paranum
end
- para='' if para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote
+ if para =~/<a name="n\d+">/ \
+ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote
+ para=''
+ end
if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/)
# i don't get the condition for no paranum
end
@@ -627,7 +642,9 @@ module SiSU_ODF
%{<style:style style:name="Table2.N" style:family="table-column"><style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/></style:style>#@br}
else ''
end
- breakpage=if @md.pagenew or @md.pagebreak; ' fo:break-before="page"'
+ breakpage=if @md.pagenew \
+ or @md.pagebreak
+ ' fo:break-before="page"'
else ''
end
@@odf[:head]<<%{<?xml version="1.0" encoding="UTF-8"?>#@br} +