Patch #1857 ยป redmine_wiki_toc.patch
redmine/lib/redmine/wiki_formatting.rb (working copy) | ||
---|---|---|
89 | 89 |
alias :textile_h3 :textile_p_withtoc |
90 | 90 |
|
91 | 91 |
def inline_toc(text) |
92 |
text.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i) do |
|
92 |
text.gsub!(/<p>\{\{([<>]?)toc(:(\d+))?\}\}<\/p>/i) do
|
|
93 | 93 |
div_class = 'toc' |
94 | 94 |
div_class << ' right' if $1 == '>' |
95 | 95 |
div_class << ' left' if $1 == '<' |
96 |
skip = 0 |
|
97 |
skip = $3.to_i if not $3.nil? |
|
96 | 98 |
out = "<ul class=\"#{div_class}\">" |
99 |
lastlevel = 1 |
|
100 |
skipped = 0 |
|
97 | 101 |
@toc.each do |heading| |
102 |
if skipped < skip |
|
103 |
skipped += 1 |
|
104 |
next |
|
105 |
end |
|
98 | 106 |
level, anchor, toc_item = heading |
107 |
if level > lastlevel |
|
108 |
out << "<li><ul>" |
|
109 |
end |
|
110 |
if level < lastlevel |
|
111 |
out << "</ul></li>" |
|
112 |
end |
|
113 |
lastlevel = level |
|
99 | 114 |
out << "<li class=\"heading#{level}\"><a href=\"##{anchor}\">#{toc_item}</a></li>\n" |
100 | 115 |
end |
116 |
while 1 < lastlevel do |
|
117 |
out << '</ul></li>' |
|
118 |
lastlevel -= 1 |
|
119 |
end |
|
101 | 120 |
out << '</ul>' |
102 |
out |
|
103 | 121 |
end |
104 | 122 |
end |
105 | 123 |
|
... | ... | |
182 | 200 |
end |
183 | 201 |
end |
184 | 202 |
end |
203 | ||
204 |
# vim: ts=2:expandtab: |
redmine/public/stylesheets/application.css (working copy) | ||
---|---|---|
476 | 476 |
div.wiki ul.toc.right { float: right; margin-left: 12px; margin-right: 0; width: auto; } |
477 | 477 |
div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; } |
478 | 478 |
div.wiki ul.toc li { list-style-type:none;} |
479 |
div.wiki ul.toc li.heading2 { margin-left: 6px; } |
|
480 |
div.wiki ul.toc li.heading3 { margin-left: 12px; font-size: 0.8em; } |
|
481 | 479 | |
482 | 480 |
div.wiki ul.toc a { |
483 | 481 |
font-size: 0.9em; |