2003年07月25日(金) プラグイン [長年日記]
[English!]
[한국어]
[今日は何の日]
§1 toc_here.rb
便利そうなので入れてみたが、00default.rbに入っているtocがリスト表示でValidなのに対して、アンカータグを<br>で折り返していた。幸いにもオプションでタグを書き換えられるのでリストに変更できそうだが実際にはリスト項目の開始タグ<li>がどうにもならない、面倒なのでプラグイン自体を少し書き換えた。
def toc_here(baseLevel = 1, page = @page)
toc_leader = @options['toc_here_leader'].nil? ? '>' : @options['toc_here_leader']
> toc_cr = @options['toc_here_cr'].nil? ? '</li>' : @options['toc_here_cr']
> toc_start = @options['toc_here_start'].nil? ? '<div class="toc"><ul>' : @options['toc_here_start']
> toc_end = @options['toc_here_end'].nil? ? '</ul></div>' : @options['toc_here_end']
toc_no_header = @options['toc_here_no_header'].nil? ? 'no header' : @options['toc_here_no_header']
toc_num = 0
s = "#{toc_start}\n"
if !page.nil? && !page.empty? && @db.exist?(page) then
@db.load(page).each_line do |line|
next if line !~ /^(!+)/
level = $1.size - baseLevel
title = line.gsub(/^!+/, "")
title.gsub!(/\[\[([^|:]+)[|:].+\]\]/, "\\1")
title.chomp!
head = title
s << toc_leader * level unless level == 0
> s << "<li><a href=\"#l#{toc_num}\" title=\"#{title}\">#{head}</a>#{toc_cr}\n"
toc_num += 1
end
end
s << toc_no_header if toc_num == 0
s << "#{toc_end}\n"
s
end
4行ほどの修正でValidなリストになるので、お悩みの方はご検討されてはと想います。ただHikiが全体をパラグラフで囲ってしまう件は今のボクにはなんともしがたいですね。:-(
[ツッコミを入れる]




