Index: hiki/plugin.rb =================================================================== RCS file: /cvsroot/hiki/hiki/hiki/plugin.rb,v retrieving revision 1.5 diff -u -r1.5 plugin.rb --- hiki/plugin.rb 26 Jul 2004 07:53:43 -0000 1.5 +++ hiki/plugin.rb 4 Nov 2004 17:01:48 -0000 @@ -8,7 +8,7 @@ module Hiki class Plugin - attr_reader :toc_f, :plugin_command + attr_reader :toc_f, :toc_re, :plugin_command attr_accessor :text, :title def initialize( options, conf ) @@ -33,6 +33,7 @@ end @toc_f = false +@toc_re = nil @plugin_command = [] @plugin_menu = [] @text = '' Index: plugin/00default.rb =================================================================== RCS file: /cvsroot/hiki/hiki/plugin/00default.rb,v retrieving revision 1.12 diff -u -r1.12 00default.rb --- plugin/00default.rb 28 Sep 2004 13:47:28 -0000 1.12 +++ plugin/00default.rb 4 Nov 2004 17:01:48 -0000 @@ -44,8 +44,9 @@ end #===== toc -def toc +def toc(pat=nil) @toc_f = true + @toc_re = Regexp.compile(pat) end #===== recent Index: style/default/html_formatter.rb =================================================================== RCS file: /cvsroot/hiki/hiki/style/default/html_formatter.rb,v retrieving revision 1.9 diff -u -r1.9 html_formatter.rb --- style/default/html_formatter.rb 14 Sep 2004 02:21:10 -0000 1.9 +++ style/default/html_formatter.rb 4 Nov 2004 17:01:48 -0000 @@ -135,30 +135,48 @@ toc_title << t[:s] if toc_level > 0 when :wikiname, :bracketname disp = t[:s] +anchor_pos = t[:href].index('#') +if anchor_pos + t[:anchor] = t[:href][anchor_pos+1..-1] + t[:href] = + if anchor_pos == 0 + then @conf.options['page'] + else t[:href][0...anchor_pos] + end +end t[:href] = @aliaswiki.aliaswiki_names.index(t[:href]) || t[:href] if t[:e] == :bracketname orig = @db.select {|p| p[:title] == t[:href]} t[:href] = orig[0] if orig[0] end +page = t[:href].escape +if t[:anchor] + page << '#' << t[:anchor].escape +end if !@conf.use_wikiname and t[:e] == :wikiname html << disp.escapeHTML elsif @db.exist?( t[:href] ) - html << @plugin.hiki_anchor(t[:href].escape, disp.escapeHTML) + html << @plugin.hiki_anchor(page, disp.escapeHTML) @references << t[:href] else missing_anchor_title = msg_missing_anchor_title % [ disp.escapeHTML ] - outer_alias = @interwiki.outer_alias(t[:href]) || "#{disp.escapeHTML}?" + outer_alias = @interwiki.outer_alias(t[:href]) || "#{disp.escapeHTML}?" html << outer_alias end - toc_title << t[:href] if toc_level > 0 + toc_title << page if toc_level > 0 when :interwiki html << @interwiki.interwiki(t[:href], t[:p], t[:s]) when :empty html << "\n" when :heading1_open, :heading2_open, :heading3_open, :heading4_open, :heading5_open toc_level = t[:lv] - html << %Q!#{MAP[t[:e]]} ! + html << %Q!#{MAP[t[:e]]}! when :heading1_close, :heading2_close, :heading3_close, :heading4_close, :heading5_close +html.sub!( //, + if @plugin.toc_re + then %Q! ! + else %Q! ! + end ) add_toc( toc_level, toc_title ) toc_level = 0 toc_title = '' @@ -215,12 +233,17 @@ s << ( "#{MAP[:unordered_list_close]}\n" * ( lv - h['level'] ) ) lv = h['level'] end - s << %Q!#{MAP[:listitem_open]}#{h['title'].escapeHTML}#{MAP[:listitem_close]}\n! + anchor = + if @plugin.toc_re + then @plugin.toc_re.match( h['title'] )[1].to_s + else "#{@suffix}#{h['index']}" + end + s << %Q!#{MAP[:listitem_open]}#{h['title'].escapeHTML}#{MAP[:listitem_close]}\n! end s << ("#{MAP[:unordered_list_close]}\n" * lv) s << "" end - + def apply_tdiary_theme(orig_html) section = '' title = ''