@@ -0,0 +1,45 | |||
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2010 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.dirname(__FILE__) + '/../../../../test_helper' | |
|
19 | ||
|
20 | class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |
|
21 | ||
|
22 | def setup | |
|
23 | @formatter = Redmine::WikiFormatting::Textile::Formatter | |
|
24 | end | |
|
25 | ||
|
26 | MODIFIERS = { | |
|
27 | "*" => 'strong', # bold | |
|
28 | "_" => 'em', # italic | |
|
29 | "+" => 'ins', # underline | |
|
30 | "-" => 'del', # deleted | |
|
31 | "^" => 'sup', # superscript | |
|
32 | "~" => 'sub' # subscript | |
|
33 | } | |
|
34 | ||
|
35 | def test_modifiers_combination | |
|
36 | MODIFIERS.each do |m1, tag1| | |
|
37 | MODIFIERS.each do |m2, tag2| | |
|
38 | next if m1 == m2 | |
|
39 | text = "#{m2}#{m1}Phrase modifiers#{m1}#{m2}" | |
|
40 | html = "<p><#{tag2}><#{tag1}>Phrase modifiers</#{tag1}></#{tag2}></p>" | |
|
41 | assert_equal html, @formatter.new(text).to_html | |
|
42 | end | |
|
43 | end | |
|
44 | end | |
|
45 | end |
@@ -373,17 +373,21 class RedCloth3 < String | |||
|
373 | 373 | ['^', 'sup', :limit], |
|
374 | 374 | ['~', 'sub', :limit] |
|
375 | 375 | ] |
|
376 | QTAGS_JOIN = QTAGS.map {|rc, ht, rtype| Regexp::quote rc}.join('|') | |
|
377 | ||
|
376 | 378 | QTAGS.collect! do |rc, ht, rtype| |
|
377 | 379 | rcq = Regexp::quote rc |
|
378 | 380 | re = |
|
379 | 381 | case rtype |
|
380 | 382 | when :limit |
|
381 | 383 | /(^|[>\s\(]) |
|
384 | (#{QTAGS_JOIN}|) | |
|
382 | 385 | (#{rcq}) |
|
383 | 386 | (#{C}) |
|
384 | 387 | (?::(\S+?))? |
|
385 |
(\w|[^\s\ |
|
|
388 | (\w|[^\s].*?[^\s]) | |
|
386 | 389 | #{rcq} |
|
390 | (#{QTAGS_JOIN}|) | |
|
387 | 391 | (?=[[:punct:]]|\s|\)|$)/x |
|
388 | 392 | else |
|
389 | 393 | /(#{rcq}) |
@@ -768,7 +772,7 class RedCloth3 < String | |||
|
768 | 772 | |
|
769 | 773 | case rtype |
|
770 | 774 | when :limit |
|
771 |
sta,qtag,atts,cite,content = $~[1.. |
|
|
775 | sta,oqs,qtag,atts,cite,content,oqa = $~[1..7] | |
|
772 | 776 | else |
|
773 | 777 | qtag,atts,cite,content = $~[1..4] |
|
774 | 778 | sta = '' |
@@ -777,7 +781,7 class RedCloth3 < String | |||
|
777 | 781 | atts << " cite=\"#{ cite }\"" if cite |
|
778 | 782 | atts = shelve( atts ) if atts |
|
779 | 783 | |
|
780 | "#{ sta }<#{ ht }#{ atts }>#{ content }</#{ ht }>" | |
|
784 | "#{ sta }#{ oqs }<#{ ht }#{ atts }>#{ content }</#{ ht }>#{ oqa }" | |
|
781 | 785 | |
|
782 | 786 | end |
|
783 | 787 | end |
General Comments 0
You need to be logged in to leave comments.
Login now