From b5c036a6cc00ed4c507d93efd2e2e2053c9786f3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 21 Nov 2011 00:06:15 -0500 Subject: v3: dal_expand_insertions, link shortcut for sisu documents, omit codeblocks --- lib/sisu/v3/dal_expand_insertions.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/sisu/v3/dal_expand_insertions.rb b/lib/sisu/v3/dal_expand_insertions.rb index cef75432..cfd8fe54 100644 --- a/lib/sisu/v3/dal_expand_insertions.rb +++ b/lib/sisu/v3/dal_expand_insertions.rb @@ -258,8 +258,16 @@ module SiSU_insertions def expand_insertions? data=@data tuned_file,tuned_file_tmp=[],[] + codeblock_=false data.each do |para| + codeblock_=if para =~/^code\{/ + true + elsif para =~/^\}code/ + false + else codeblock_ + end if para !~/^%+\s/ \ + and not codeblock_ \ and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ txt,cmd,source,linked_doc,note,manifest=nil,nil,nil,nil,nil,nil @u=SiSU_Env::Info_env.new.url -- cgit v1.2.3 From b19886a01a945ea846f51956ec201f9f32e1eca5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 21 Nov 2011 00:11:52 -0500 Subject: v3: param, sisupod_make, sisu markup embedded symbol images regex, case added --- lib/sisu/v3/dal_syntax.rb | 2 +- lib/sisu/v3/param.rb | 3 ++- lib/sisu/v3/sisupod_make.rb | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 3a943b75..e51316ed 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -342,7 +342,7 @@ module SiSU_Syntax end end dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup - dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu') #adjustment 2005w30 + dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') dob.obj.gsub!(//,'<:\1>') #escaped special character dob.obj.gsub!(/ /,"#{Mx[:nbsp]}") #escaped special character dob.obj.gsub!(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index ef8e9389..045fd767 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -966,7 +966,7 @@ module SiSU_Param @lang_code_insert=(@opt.dir_structure_by =~/language/) \ ? '' : ".#{@opt.lng}" - @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg begin @@ -1272,6 +1272,7 @@ module SiSU_Param end end end + para.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if para !~/^%+\s/ \ and para =~@rgx_image @ec[:image] << para.scan(@rgx_image).uniq diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index b154bc1d..e4423641 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -160,8 +160,8 @@ module SiSU_Doc end @skin end - def images_extract(f,images) - rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + def images_extract(f,images) # consider using param info + rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m if f !~/^%+\s/ \ and f =~rgx_image images << f.scan(rgx_image).uniq @@ -183,6 +183,7 @@ module SiSU_Doc file_array.each do |f| #% work area if f !~/^%+\s/ skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin + f.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) -- cgit v1.2.3 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