aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2008-09-13 00:53:58 -0400
committerRalph Amissah <ralph@amissah.com>2008-09-13 00:53:58 -0400
commitb3f2c67fd2d5b6c396eada917e2ef6dc069e5ea3 (patch)
tree710252bdfebf36e3747149874a3b5d740c0d403f
parentdal_idx: strip before sort; fix bug where first lev is range (diff)
dal_idx: capitalize first letter of index lev1 for sort; provide letter a-z navigation
-rw-r--r--lib/sisu/v0/dal_idx.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb
index f8eb5e45..9691a997 100644
--- a/lib/sisu/v0/dal_idx.rb
+++ b/lib/sisu/v0/dal_idx.rb
@@ -131,6 +131,7 @@ module SiSU_book_index
use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2]
else use=idx_lst[0]
end
+ use=use[0].chr.capitalize + use[1,use.length]
@the_idx[use]={} unless @the_idx[use] and defined? @the_idx[use]
idx_lst.each do |i|
i.strip!
@@ -168,12 +169,25 @@ module SiSU_book_index
@idx[:sst] << "\n\n#{Mx[:br_page_new]}"
@idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}"
@idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}"
+ @alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
+ @idx[:html] << '<p>'
+ @alph.each {|x| @idx[:html] << %{<a href="##{x}">#{x}</a>,&nbsp;}}
+ @idx[:html] << '</p>'
+ @letter=@alph.shift
+ @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="A">A</a></p>}
the_idx.each do |i|
i.each do |x|
if x.class == String
+ f=/^(\S)/.match(x)[1]
+ if @letter < f
+ while @letter < f
+ @letter=@alph.shift
+ @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="#{@letter}">#{@letter}</a></p>}
+ end
+ end
@idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} }
aname=x.gsub(/\s+/,'_')
- @idx[:html] << %{\n<p class="book_index_lev1"><a name="##{aname}"><b>#{x}</b></a>, }
+ @idx[:html] << %{\n<p class="book_index_lev1"><a name="#{aname}"><b>#{x}</b></a>, }
@o=@idx[:sst].index(@idx[:sst].last) #@o=@idx[:sst].length - 1
@q=@idx[:html].index(@idx[:html].last) #@o=@idx[:html].length - 1
print "\n" + x + ', ' if @md.cmd =~/V/