Defect #2038 ยป 2038_git.diff
lib/redmine/wiki_formatting/textile/formatter.rb | ||
---|---|---|
65 | 65 |
def textile_p_withtoc(tag, atts, cite, content) |
66 | 66 |
# removes wiki links from the item |
67 | 67 |
toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 } |
68 |
# sanitizes titles from links |
|
69 |
# see redcloth3.rb, same as "#{pre}#{text}#{post}" |
|
70 |
toc_item.gsub!(LINK_RE) { $2+$4+$9 } |
|
71 |
# removes styles |
|
72 |
# eg. %{color:red}Triggers% => Triggers |
|
73 |
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1' |
|
68 |
|
|
69 |
# removes inline textile |
|
70 |
toc_item = RedCloth3.new(toc_item).to_html.gsub(/<[^>]+?>/,'') |
|
74 | 71 |
|
75 | 72 |
# replaces non word caracters by dashes |
76 | 73 |
anchor = toc_item.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-') |
test/unit/helpers/application_helper_test.rb | ||
---|---|---|
421 | 421 |
h1. Another title |
422 | 422 | |
423 | 423 |
h2. An "Internet link":http://www.redmine.org/ inside subtitle |
424 | ||
425 |
h2. @Subtitle@ *with* _various_ -stupid- +styles+ |
|
424 | 426 |
RAW |
425 | 427 | |
426 | 428 |
expected = '<ul class="toc">' + |
... | ... | |
430 | 432 |
'<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' + |
431 | 433 |
'<li class="heading1"><a href="#Another-title">Another title</a></li>' + |
432 | 434 |
'<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' + |
435 |
'<li class="heading2"><a href="#Subtitle-with-various-stupid-styles">Subtitle with various stupid styles</a></li>' + |
|
433 | 436 |
'</ul>' |
434 | 437 |
|
435 | 438 |
assert textilizable(raw).gsub("\n", "").include?(expected) |