summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-07-19 14:23:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-07-19 14:23:15 +0000
commitdcba9f18e6f3a19af85bb66843eb97107805bb75 (patch)
tree4c0dcb8d7a46ee17dfe4b28a820f46eb37a18eca
parent5ec4d4cdab31509ff7afa5a9415850885885a6c4 (diff)
downloadredmine-dcba9f18e6f3a19af85bb66843eb97107805bb75.tar.gz
redmine-dcba9f18e6f3a19af85bb66843eb97107805bb75.zip
Allow line breaks in wiki table cells (#2346).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2824 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redcloth3.rb9
-rw-r--r--lib/redmine/wiki_formatting/textile/formatter.rb2
-rw-r--r--test/unit/helpers/application_helper_test.rb41
3 files changed, 48 insertions, 4 deletions
diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb
index a4d33f804..e99ccdf77 100644
--- a/lib/redcloth3.rb
+++ b/lib/redcloth3.rb
@@ -784,6 +784,7 @@ class RedCloth3 < String
end
LINK_RE = /
+ (
([\s\[{(]|[#{PUNCT}])? # $pre
" # start
(#{C}) # $atts
@@ -797,13 +798,16 @@ class RedCloth3 < String
)
(\/)? # $slash
([^\w\=\/;\(\)]*?) # $post
+ )
(?=<|\s|$)
/x
#"
def inline_textile_link( text )
text.gsub!( LINK_RE ) do |m|
- pre,atts,text,title,url,proto,slash,post = $~[1..8]
-
+ all,pre,atts,text,title,url,proto,slash,post = $~[1..9]
+ if text.include?('<br />')
+ all
+ else
url, url_title = check_refs( url )
title ||= url_title
@@ -821,6 +825,7 @@ class RedCloth3 < String
external = (url =~ /^https?:\/\//) ? ' class="external"' : ''
"#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }"
+ end
end
end
diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb
index 67e3579df..7e20c7bfc 100644
--- a/lib/redmine/wiki_formatting/textile/formatter.rb
+++ b/lib/redmine/wiki_formatting/textile/formatter.rb
@@ -44,7 +44,7 @@ module Redmine
# Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
# <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
def hard_break( text )
- text.gsub!( /(.)\n(?!\n|\Z|>| *(>? *[#*=]+(\s|$)|[{|]))/, "\\1<br />\n" ) if hard_breaks
+ text.gsub!( /(.)\n(?!\n|\Z|>| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
end
# Patch to add code highlighting support to RedCloth
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 4d7719567..2dc506702 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -109,7 +109,7 @@ class ApplicationHelperTest < HelperTestCase
'"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with &quot;double-quotes&quot;" class="external">link</a>',
"This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
# no multiline link text
- "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line<br />\nand another on a second line\":test",
+ "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line<br />and another on a second line\":test",
# mailto link
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
# two exclamation marks
@@ -396,6 +396,45 @@ EXPECTED
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
end
+ def test_table_with_line_breaks
+ raw = <<-RAW
+This is a table with line breaks:
+
+|cell11
+continued|cell12||
+|-cell21-||cell23
+cell23 line2
+cell23 *line3*|
+|cell31|cell32
+cell32 line2|cell33|
+
+RAW
+
+ expected = <<-EXPECTED
+<p>This is a table with line breaks:</p>
+
+<table>
+ <tr>
+ <td>cell11<br />continued</td>
+ <td>cell12</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td><del>cell21</del></td>
+ <td></td>
+ <td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td>
+ </tr>
+ <tr>
+ <td>cell31</td>
+ <td>cell32<br/>cell32 line2</td>
+ <td>cell33</td>
+ </tr>
+</table>
+EXPECTED
+
+ assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
+ end
+
def test_default_formatter
Setting.text_formatting = 'unknown'
text = 'a *link*: http://www.example.net/'
3 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643