diff options
| author | Ralph Amissah <ralph@amissah.com> | 2012-10-01 15:27:56 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2012-10-01 15:27:56 -0400 | 
| commit | 58c13f49d81e3a6448a0f4dabf44b3bfb52ea84c (patch) | |
| tree | f69d4a34d9c7b9b70572308f46cc3de071d0437c | |
| parent | v3: vim syntax, sisu.vim, =\\= page new & -\\- page break (diff) | |
v3: odf, internal links/bookmarks, toc, book index
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 2 | ||||
| -rw-r--r-- | lib/sisu/v3/dal.rb | 14 | ||||
| -rw-r--r-- | lib/sisu/v3/odf.rb | 170 | ||||
| -rw-r--r-- | lib/sisu/v3/odf_format.rb | 60 | ||||
| -rw-r--r-- | lib/sisu/v3/particulars.rb | 10 | ||||
| -rw-r--r-- | lib/sisu/v3/sysenv.rb | 4 | ||||
| -rw-r--r-- | lib/sisu/v3/texpdf.rb | 2 | 
7 files changed, 166 insertions, 96 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index fdbe9c0b..3b0f7126 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -48,6 +48,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.3.orig.tar.xz  * v3: sisupod source, paths fix +* v3: odf, internal links/bookmarks, toc, book index +  * v3: pdflatex, fixes    * landscape cover page was botched, came out as portrait diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index 6c7fef79..a039545f 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -100,7 +100,7 @@ module SiSU_DAL        @fnm=@make_fns.marshal.dal_metadata        @fnc=@make_fns.marshal.dal_content        @idx_sst=@make_fns.marshal.dal_idx_sst_rel_html_seg -      @idx_tex=@make_fns.marshal.dal_idx_sst_rel +      @idx_raw=@make_fns.marshal.dal_idx_sst_rel        @idx_html=@make_fns.marshal.dal_idx_html        @idx_xhtml=@make_fns.marshal.dal_idx_xhtml        @map_nametags=@make_fns.marshal.dal_map_nametags @@ -163,7 +163,7 @@ module SiSU_DAL          SiSU_DAL::Instantiate.new        end      end -    def get_idx_tex                                                            #reads dal idx.tex, #unless does not exist then creates first +    def get_idx_raw        begin          dal=[]          unless @@fns==@opt.fns \ @@ -173,7 +173,7 @@ module SiSU_DAL            : @opt.fns            @@idx_arr[:tex]=[]          end -        dal=(@@idx_arr[:tex].empty?) ? read_idx_tex : @@idx_arr[:tex].dup #check +        dal=(@@idx_arr[:tex].empty?) ? read_idx_raw : @@idx_arr[:tex].dup #check        rescue          SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error do            __LINE__.to_s + ':' + __FILE__ @@ -318,12 +318,12 @@ module SiSU_DAL        else nil        end      end -    def read_idx_tex +    def read_idx_raw        m=[] -      m=if FileTest.file?(@idx_tex) +      m=if FileTest.file?(@idx_raw)          (RUBY_VERSION < '1.9') \ -        ? (File.open(@idx_tex){ |f| m=Marshal.load(f)}) -        : (File.open(@idx_tex,'r:utf-8'){ |f| m=Marshal.load(f)}) +        ? (File.open(@idx_raw){ |f| m=Marshal.load(f)}) +        : (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)})        else nil        end      end diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 4985b3dd..2830b24d 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -101,7 +101,7 @@ module SiSU_ODF        require_relative 'defaults'                       # defaults.rb        require_relative 'shared_txt'                     # shared_txt.rb        @@img_count=0 -      @@odf={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] } +      @@odf={ body: [], head: [], toc: [],  metadata: [], tail: [], book_idx: [], endnotes: [] }        @@docstart=true        @@fns=nil        def initialize(particulars) @@ -144,6 +144,19 @@ module SiSU_ODF            end          end        end +      def odf_book_idx +      if @md.book_idx +        idx_arr,idx_raw=[],SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx +        idx_raw.each do |x| +          x=if x.is_a?(String) +            SiSU_ODF_Format::FormatBookIndex.new(x).book_idx_bookmark +          else nil +          end +          idx_arr << x.strip if x.is_a?(String) +        end +        @@odf[:book_idx]=idx_arr.join +      end +      end        def odf_metadata          @@odf[:metadata]=SiSU_Metadata::Summary.new(@md).odf.metadata        end @@ -162,8 +175,10 @@ module SiSU_ODF          @@odf[:tail] << %{\n<text:p text:style-name="P_normal">SiSU: <<text:a xlink:type="simple" xlink:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>> and <<text:a xlink:type="simple" xlink:href="http://www.sisudoc.org">www.sisudoc.org</text:a>></text:p>}          @@odf[:tail] << "\n</office:text></office:body></office:document-content>"        end -      def heading(dob,p_num='') -        dob.obj=dob.obj.gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check +      def set_bookmark_tag(dob) +        tags=SiSU_ODF_Format::Tags.new.set_bookmark_tag(dob) +      end +      def heading(dob,p_num)          m=/#{$1}/          breakpage=''          if @md.fns \ @@ -180,7 +195,19 @@ module SiSU_ODF            end          end          @@docstart=false -        dob.obj=%{#{breakpage}<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">#{dob.obj}#{p_num}</text:h>} +        dob.tmp=dob.obj +        dob.obj=%{#{breakpage}<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:h>} +        dob +      end +      def toc(dob,p_num) +        m=/#{$1}/ +        hardspace=(dob.lv =~/[A-C]/i) \ +        ? '<text:p text:style-name="Standard"/>' +        : '' +        toc_heading=dob.ocn \ +        ? %{<text:bookmark-ref text:reference-format="text" text:ref-name="#{dob.ocn}">#{dob.tmp}</text:bookmark-ref>} +        : dob.tmp +        dob.obj=%{<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">#{toc_heading}</text:h>#{hardspace}}          dob        end        def image_src(i) @@ -282,6 +309,10 @@ module SiSU_ODF          end          t        end +      def text_link_odf_bookmark(txt,url,trail) +        map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map +        %{<text:bookmark-ref text:reference-format="text" text:ref-name="#{url}">#{txt.strip}</text:bookmark-ref>#{trail}} +      end        def text_link(dob)          m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/) #sort          if m @@ -305,6 +336,19 @@ module SiSU_ODF              txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").                gsub(/([+?*])/,"\\\\\\1") # problems with +              url=url.gsub(/([+?])/,"\\\\\\1") # problems with + +            dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf_bookmark(txt,url,trail)). #make sure trailing ']' are not caught in url +              gsub(/\\([)(\]\[?])/,'\1') #clumsy fix +          end +          m=nil +        end +        dob +      end +      def text_link_relative_(dob) +        m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort +        if m +          m.each do |i| +            txt,url,trail=i[1],i[2] +            txt=txt.gsub(/([)(\]\[])/,"\\\\\\1")              dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url                gsub(/\\([)(\]\[?])/,'\1') #clumsy fix            end @@ -312,7 +356,7 @@ module SiSU_ODF          end          dob        end -      def normal(dob,p_num='')                                                           #P1 - P3 +      def normal(dob,p_num)                                                           #P1 - P3          dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,              '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration            gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, @@ -322,12 +366,12 @@ module SiSU_ODF          dob.obj= if dob.is==:para \          and dob.indent.to_s =~/[0-9]/ \          and dob.indent == dob.hang -          %{<text:p text:style-name="P_indent_#{dob.indent}">#{dob.obj}#{p_num}</text:p>} +          %{<text:p text:style-name="P_indent_#{dob.indent}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}          elsif dob.is==:para \          and dob.hang.to_s =~/[0-9]/ \          and dob.indent != dob.hang -          %{<text:p text:style-name="P_h#{dob.hang}_i#{dob.indent}">#{dob.obj}#{p_num}</text:p>} -        else %{<text:p text:style-name="P_normal">#{dob.obj}#{p_num}</text:p>} +          %{<text:p text:style-name="P_h#{dob.hang}_i#{dob.indent}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>} +        else %{<text:p text:style-name="P_normal">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}          end          dob        end @@ -390,12 +434,13 @@ module SiSU_ODF        end        def poem(dob,p_num)                                                             #P4 #same as group          parray=[] -        dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| +        dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| +          set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''            parablock=group_clean(parablock) -          parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/ +          parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/          end          dob.obj=parray.join \ -        + %{<text:p text:style-name="P_group">#{p_num}</text:p>} \ +        + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \          + '<text:p text:style-name="Standard"/>'          dob        end @@ -407,7 +452,8 @@ module SiSU_ODF              %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}).            gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,              %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration -        dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| +        dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| +          set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''            parablock=group_clean(parablock)            parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">').              gsub(/<(\/text:a)>/,'<\1>'). @@ -415,10 +461,10 @@ module SiSU_ODF              gsub(/<(text:p text:style-name="Footnote")>/,'<\1>').              gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>')            parablock=footnote(parablock) -          parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/ +          parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/          end          dob.obj=parray.join \ -        + %{<text:p text:style-name="P_group">#{p_num}</text:p>} \ +        + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \          + '<text:p text:style-name="Standard"/>'          dob        end @@ -430,7 +476,8 @@ module SiSU_ODF              %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}).            gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,              %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration -        dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| +        dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| +          set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''            parablock=group_clean(parablock)            parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">').              gsub(/<(\/text:a)>/,'<\1>'). @@ -438,10 +485,10 @@ module SiSU_ODF              gsub(/<(text:p text:style-name="Footnote")>/,'<\1>').              gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>')            parablock=footnote(parablock) -          parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/ +          parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/          end          dob.obj=parray.join \ -        + %{<text:p text:style-name="P_group">#{p_num}</text:p>} \ +        + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \          + '<text:p text:style-name="Standard"/>'          dob        end @@ -449,15 +496,16 @@ module SiSU_ODF          if dob.is==:code            dob.obj=dob.obj.gsub(/\s\s/,'  ')            parray=[] -          dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| +          dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| +            set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''              parablock=group_clean(parablock)              parablock=parablock.gsub(/^\s*$/,'<br />').                gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,                  '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration -            parray << %{<text:p text:style-name="P_code">#{parablock}</text:p>} if parablock =~/\S+/ +            parray << %{<text:p text:style-name="P_code">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/            end            dob.obj=parray.join \ -          + %{<text:p text:style-name="P_group">#{p_num}</text:p>} \ +          + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \            + '<text:p text:style-name="Standard"/>'          end          dob @@ -490,18 +538,22 @@ module SiSU_ODF            dob          else dob          end -        p_num='' -        if @env.odt_ocn? -          if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ -            if defined? dob.ocn \ -            and not dob.ocn.nil? -              p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).display -            end +        p_num={ display: '', set_ref: '' } +        if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ +          if defined? dob.ocn \ +          and dob.ocn.is_a?(Fixnum) +            p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display +            #p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_ref_and_display            end          end          dob=footnote(dob)          if dob.is==:heading            @@odf[:body] << heading(dob,p_num).obj << @br*2 +          if SiSU_Env::ProcessingSettings.new(md).build.toc? +            if dob.lv =~/[A-C1]/i +              @@odf[:toc] << toc(dob,p_num).obj +            end +          end          elsif dob.is ==:verse            @@odf[:body] << poem(dob,p_num).obj << @br*2          elsif dob.is==:group @@ -539,6 +591,7 @@ module SiSU_ODF            else STDERR.puts %{\t*WARN* did not find image - "#{bullet}/bullet_09.png" [#{__FILE__}:#{__LINE__}]}            end          end +        odf_book_idx          odf_metadata          data.each do |dob|            #p dob.obj if dob.obj =~safe_characters and @md.opt.cmd =~/V/ #KEEP @@ -573,7 +626,7 @@ module SiSU_ODF            dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').              gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').              gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>'). -            gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check +            gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'<text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/>'). #check              gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').              gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').              gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'') @@ -693,14 +746,19 @@ WOK        def publish          divider='='          content=[] +        br_pg='<text:p text:style-name="P_normal_page_new"> </text:p>'          data=@data -        content << @@odf[:open] -        content << @@odf[:head] -        content << @@odf[:body] -        content << @@odf[:metadata] -        content << @@odf[:tail] +        content << +          @@odf[:head] << +          @@odf[:toc] << +          br_pg << +          @@odf[:body] << +          @@odf[:book_idx] << +          br_pg << +          @@odf[:metadata] << +          @@odf[:tail]          SiSU_ODF::Source::Output.new(content,@md,@env).odf -        @@odf[:head],@@odf[:body],@@odf[:tail],@@odf[:metadata]=[],[],[],[] +        @@odf={ head: [], toc: [], body: [], tail: [], book_idx: [], metadata: [] }        end      end      class Output <Source @@ -739,7 +797,7 @@ WOK          env.make_path(@md.file.output_path.odt.dir)          filename="#{@env.processing_path.odt}/content.xml"          od=File.new(filename,'w+') -        @content.each do |para|                                                # this is a hack +        @content.compact.each do |para|                                                # this is a hack            od.puts para unless para =~/\A\s*\Z/          end          od.close @@ -759,45 +817,3 @@ WOK    end  end  __END__ -todo: -* table of contents -* page header/footer? - -done: -headings                              * -footnotes                             * -bold underscore italics strikethrough * -superscript subscript                 * -extended ascii set                    * -indents                               * -  [autonomy_markup0.sst]              * -groups -  poem                                * -  code                                * -  tables -images -bullet -line break -page break - -notes?? [you could add a note number for every object/paragraph!] - -        FileUtils::cd(@env.processing_path.odt) -        structure=[] -        Find.find(@env.processing_path.odt) do |f| -          structure << puts f -        end -        open(opendoc,'wb') do |f| -          zip=Zlib::ZipWriter.new(f) -          structure.each |z| do -            zip << z -          end -          zip.close -        end -        #zip -qr #{opendoc} * -        FileUtils::mv(opendoc,"#{@env.path.output}/#{@md.fnb}/.") -        FileUtils::cd(Dir.pwd) -● -<text:span text:style-name="T6">●</text:span>     #bullet -dob.obj.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*#{Mx[:gl_bullet]}/,'\1 <text:span text:style-name="T6">·</text:span> ') #bullet -dob.obj.gsub!(/^#{Mx[:gl_bullet]}/,'<text:span text:style-name="T6">·</text:span> ') #bullet diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index ae5c4aec..cd998f43 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -63,8 +63,15 @@ module SiSU_ODF_Format      def initialize(paranum)        @paranum=/(\d+)/m.match(paranum.to_s)[1]      end -    def display -      @paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') +    def set_ref_and_display +      set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:reference-mark-start text:name="\1"/><text:reference-mark-end text:name="\1"/></text:span>') +      disp=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') +      ocn={ display: disp, set_ref: set_ref } +    end +    def set_bookmark_and_display +      set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/></text:span>') +      disp=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') +      ocn={ display: disp, set_ref: set_ref }      end      def name        @paranum.gsub(/(\d+)/,'<a name="\1"></a>') @@ -73,6 +80,50 @@ module SiSU_ODF_Format        @paranum.gsub(/(\d+)/,'<a href="#\1">')      end    end +  class FormatBookIndex +    def initialize(idx_str) +      @idx_str=idx_str +    end +    def book_idx_bookmark +      map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags +      rgx_bookmark=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m +      while @idx_str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}#?(\S+?)#{Mx[:rel_c]}/m +        link,url=$1,$2 +        link,url=link.strip,url.strip +        @idx_str=@idx_str.gsub(/&/m,"&") +        ocn_lnk=if map_nametags[url] \ +        and map_nametags[url][:ocn] +          map_nametags[url][:ocn] +        else nil +        end +        ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk) +        if ocn_lnk and not ocn_lnk.empty? +          @idx_str=@idx_str.sub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, +              '<text:span text:style-name="Span_bold">\1</text:span>'). +            sub(rgx_bookmark, +              %{<text:bookmark-ref text:reference-format="text" text:ref-name="#{url}">#{link.strip}</text:bookmark-ref>}) +        else +          puts %{name tag: "#{url}" not found} +          @idx_str.sub!(rgx_bookmark,"#{link}") +        end +      end +      @idx_str=@idx_str.gsub(/#{Xx[:protect]}/m,''). +        sub(/,\s*$/m,''). +        gsub(/\n/,'') +      @idx_str='<text:p text:style-name="P_normal">' + @idx_str + '</text:p>' +    end +  end +  class Tags +    def set_bookmark_tag(dob) +      tags='' +      if dob.tags.length > 0 +        dob.tags.each do |tag| +          tags +=%{ <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="#{tag}"/><text:bookmark-end text:name="#{tag}"/></text:span>} +        end +      end +      tags +    end +  end    class FormatTextObject      def initialize(md,t_o)        @md,@t_o=md,t_o @@ -136,12 +187,13 @@ module SiSU_ODF_Format        when 14; 'N'        else     'D'        end -      %{<table:table table:name="Table#{count}" table:style-name="Table#{type}">#{@br}} + +      tag=SiSU_ODF_Format::Tags.new.set_bookmark_tag(@dob) +      %{<table:table table:name="Table#{count}" table:style-name="Table#{type}">#{@p_num[:set_ref]}#{tag}#{@br}} +        %{<table:table-column table:style-name="Table#{type}.#{alpha}" table:number-columns-repeated="#{@dob.cols}"/>#{@br}}      end      def table_close(tablefoot='')        '</table:table>' \ -      + %{<text:p text:style-name="P_group">#{@p_num}</text:p>} +      + %{<text:p text:style-name="P_group">#{@p_num[:display]}</text:p>}      end      def table_tag_cell(str,i)        txt_name_cell=if i==0 \ diff --git a/lib/sisu/v3/particulars.rb b/lib/sisu/v3/particulars.rb index b95ba52a..97a3da3e 100644 --- a/lib/sisu/v3/particulars.rb +++ b/lib/sisu/v3/particulars.rb @@ -97,9 +97,9 @@ module SiSU_Particulars        @opt=opt        set_sst_idx      end -    def get_idx_tex(opt) +    def get_idx_raw(opt)        @opt=opt -      set_tex_idx +      set_raw_idx      end      def get_idx_html(opt)        @opt=opt @@ -126,7 +126,7 @@ module SiSU_Particulars        @opt=opt        set_ocn_htmlseg_map      end -    attr_accessor :opt,:md,:sst_idx,:tex_idx,:html_idx,:xhtml_idx +    attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx      def set_md        begin          @md=SiSU_Param::Parameters.new(@opt).get @@ -180,9 +180,9 @@ module SiSU_Particulars          end        end      end -    def set_tex_idx +    def set_raw_idx        begin -        @tex_idx=SiSU_DAL::Source.new(@opt).get_idx_tex +        @raw_idx=SiSU_DAL::Source.new(@opt).get_idx_raw          self        rescue          SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error do diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index be13c4fc..0786119c 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -3465,8 +3465,8 @@ WOK        def dal_idx_sst_rel_html_seg          "#{@env.processing_path.dal}/#{@fns}.idx_sst.rbm"        end -      def dal_idx_sst_rel -        "#{@env.processing_path.dal}/#{@fns}.idx_tex.rbm" +      def dal_idx_sst_rel #used by tex & odf +        "#{@env.processing_path.dal}/#{@fns}.idx_raw.rbm"        end        def dal_idx_html          "#{@env.processing_path.dal}/#{@fns}.idx_html.rbm" diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 618c891e..aba92c3e 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -535,7 +535,7 @@ module SiSU_TeX                h=tst.heading_major                heading="\\clearpage\n" + h.tmp                idx_arr=[] -              idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_tex(@md.opt).tex_idx +              idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx                idx.each do |x|                  x=if x.class==String                    x=SiSU_TeX_Pdf::SpecialCharacters.new(@md,x).special_characters  | 
