@@ -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 | ['^', 'sup', :limit], |
|
373 | ['^', 'sup', :limit], | |
374 | ['~', 'sub', :limit] |
|
374 | ['~', 'sub', :limit] | |
375 | ] |
|
375 | ] | |
|
376 | QTAGS_JOIN = QTAGS.map {|rc, ht, rtype| Regexp::quote rc}.join('|') | |||
|
377 | ||||
376 | QTAGS.collect! do |rc, ht, rtype| |
|
378 | QTAGS.collect! do |rc, ht, rtype| | |
377 | rcq = Regexp::quote rc |
|
379 | rcq = Regexp::quote rc | |
378 | re = |
|
380 | re = | |
379 | case rtype |
|
381 | case rtype | |
380 | when :limit |
|
382 | when :limit | |
381 | /(^|[>\s\(]) |
|
383 | /(^|[>\s\(]) | |
|
384 | (#{QTAGS_JOIN}|) | |||
382 | (#{rcq}) |
|
385 | (#{rcq}) | |
383 | (#{C}) |
|
386 | (#{C}) | |
384 | (?::(\S+?))? |
|
387 | (?::(\S+?))? | |
385 |
(\w|[^\s\ |
|
388 | (\w|[^\s].*?[^\s]) | |
386 | #{rcq} |
|
389 | #{rcq} | |
|
390 | (#{QTAGS_JOIN}|) | |||
387 | (?=[[:punct:]]|\s|\)|$)/x |
|
391 | (?=[[:punct:]]|\s|\)|$)/x | |
388 | else |
|
392 | else | |
389 | /(#{rcq}) |
|
393 | /(#{rcq}) | |
@@ -768,7 +772,7 class RedCloth3 < String | |||||
768 |
|
772 | |||
769 | case rtype |
|
773 | case rtype | |
770 | when :limit |
|
774 | when :limit | |
771 |
sta,qtag,atts,cite,content = $~[1.. |
|
775 | sta,oqs,qtag,atts,cite,content,oqa = $~[1..7] | |
772 | else |
|
776 | else | |
773 | qtag,atts,cite,content = $~[1..4] |
|
777 | qtag,atts,cite,content = $~[1..4] | |
774 | sta = '' |
|
778 | sta = '' | |
@@ -777,7 +781,7 class RedCloth3 < String | |||||
777 | atts << " cite=\"#{ cite }\"" if cite |
|
781 | atts << " cite=\"#{ cite }\"" if cite | |
778 | atts = shelve( atts ) if atts |
|
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 | end |
|
786 | end | |
783 | end |
|
787 | end |
General Comments 0
You need to be logged in to leave comments.
Login now