Class: SiSU_XML_ODF_ODT_Format::FormatBookIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/xml_odf_odt_format.rb

Instance Method Summary collapse

Constructor Details

#initialize(idx_str) ⇒ FormatBookIndex

Returns a new instance of FormatBookIndex.



89
90
91
# File 'lib/sisu/xml_odf_odt_format.rb', line 89

def initialize(idx_str)
  @idx_str=idx_str
end

Instance Method Details

#book_idx_bookmarkObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/sisu/xml_odf_odt_format.rb', line 92

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