Commit 7e0ffa0d authored by jplang's avatar jplang

Add "Table of contents" heading to toc macro (#23179).

git-svn-id: https://svn.redmine.org/redmine/trunk@15992 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 23f48874
......@@ -1012,7 +1012,7 @@ module ApplicationHelper
div_class = 'toc'
div_class << ' right' if right_align
div_class << ' left' if left_align
out = "<ul class=\"#{div_class}\"><li>"
out = "<ul class=\"#{div_class}\"><li><strong>#{l :label_table_of_contents}</strong></li><li>"
root = headings.map(&:first).min
current = root
started = false
......
......@@ -1210,6 +1210,7 @@ de:
label_new_project_issue_tab_enabled: Tab "Neues Ticket" anzeigen
setting_new_item_menu_tab: Menü zum Anlegen neuer Objekte
label_new_object_tab_enabled: Dropdown-Menü "+" anzeigen
label_table_of_contents: Inhaltsverzeichnis
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
field_textarea_font: Font used for text areas
......
......@@ -1000,6 +1000,7 @@ en:
label_relations: Relations
label_new_project_issue_tab_enabled: Display the "New issue" tab
label_new_object_tab_enabled: Display the "+" drop-down
label_table_of_contents: Table of contents
label_font_default: Default font
label_font_monospace: Monospaced font
label_font_proportional: Proportional font
......
......@@ -1009,6 +1009,7 @@ fr:
label_relations: Relations
label_new_project_issue_tab_enabled: Afficher l'onglet "Nouvelle demande"
label_new_object_tab_enabled: Afficher le menu déroulant "+"
label_table_of_contents: Contenu
label_font_default: Police par défaut
label_font_monospace: Police non proportionnelle
label_font_proportional: Police proportionnelle
......
......@@ -1013,6 +1013,7 @@ div.wiki ul.toc.right { float: right; margin-left: 12px; margin-right: 0; width:
div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; }
div.wiki ul.toc ul { margin: 0; padding: 0; }
div.wiki ul.toc li {list-style-type:none; margin: 0; font-size:12px;}
div.wiki ul.toc>li:first-child {margin-bottom: .5em; color: #777;}
div.wiki ul.toc li li {margin-left: 1.5em; font-size:10px;}
div.wiki ul.toc a {
font-size: 0.9em;
......
......@@ -1092,6 +1092,8 @@ EXPECTED
end
def test_table_of_content
set_language_if_valid 'en'
raw = <<-RAW
{{toc}}
......@@ -1124,6 +1126,7 @@ h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.p
RAW
expected = '<ul class="toc">' +
'<li><strong>Table of contents</strong></li>' +
'<li><a href="#Title">Title</a>' +
'<ul>' +
'<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
......@@ -1153,6 +1156,8 @@ RAW
end
def test_table_of_content_should_generate_unique_anchors
set_language_if_valid 'en'
raw = <<-RAW
{{toc}}
......@@ -1164,6 +1169,7 @@ h2. Subtitle
RAW
expected = '<ul class="toc">' +
'<li><strong>Table of contents</strong></li>' +
'<li><a href="#Title">Title</a>' +
'<ul>' +
'<li><a href="#Subtitle">Subtitle</a></li>' +
......@@ -1180,6 +1186,8 @@ RAW
end
def test_table_of_content_should_contain_included_page_headings
set_language_if_valid 'en'
raw = <<-RAW
{{toc}}
......@@ -1189,6 +1197,7 @@ h1. Included
RAW
expected = '<ul class="toc">' +
'<li><strong>Table of contents</strong></li>' +
'<li><a href="#Included">Included</a></li>' +
'<li><a href="#Child-page-1">Child page 1</a></li>' +
'</ul>'
......
......@@ -239,6 +239,8 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
end
def test_macro_collapse_should_not_break_toc
set_language_if_valid 'en'
text = <<-RAW
{{toc}}
......@@ -249,7 +251,7 @@ h2. Heading
}}"
RAW
expected_toc = '<ul class="toc"><li><a href="#Title">Title</a><ul><li><a href="#Heading">Heading</a></li></ul></li></ul>'
expected_toc = '<ul class="toc"><li><strong>Table of contents</strong></li><li><a href="#Title">Title</a><ul><li><a href="#Heading">Heading</a></li></ul></li></ul>'
assert_include expected_toc, textilizable(text).gsub(/[\r\n]/, '')
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment