1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.wiki.translators;
16  
17  /**
18   * <a href="ClassicToCreoleTranslator.java.html"><b><i>View Source</i></b></a>
19   *
20   * @author Jorge Ferrer
21   */
22  public class ClassicToCreoleTranslator extends BaseTranslator {
23  
24      public ClassicToCreoleTranslator() {
25          initRegexps();
26      }
27  
28      protected void initRegexps() {
29  
30          // Bold and italics
31  
32          regexps.put(
33              "'''''((?s:.)*?)('''''|(\n\n|\r\r|\r\n\r\n))", "**//$1//**$3");
34  
35          // Bold
36  
37          regexps.put("'''((?s:.)*?)('''|(\n\n|\r\r|\r\n\r\n))", "**$1**$3");
38  
39          // Italics
40  
41          regexps.put("''((?s:.)*?)(''|(\n\n|\r\r|\r\n\r\n))", "//$1//$3");
42  
43          // Link
44  
45          regexps.put("\\[([^ ]*)\\]", "[[$1]]");
46  
47          // Link with label
48  
49          regexps.put("\\[([^ ]+) (.*)\\]", "[[$1|$2]]");
50  
51          // Monospace
52  
53          regexps.put("(^ (.+))(\\n (.+))*", "{{{\n$0\n}}}");
54  
55          // List item
56  
57          regexps.put("^\\t[\\*] (.*)", "* $1");
58  
59          // List subitem
60  
61          regexps.put("^\\t\\t[\\*] (.*)", "** $1");
62  
63          // List subsubitem
64  
65          regexps.put("^\\t\\t\\t[\\*] (.*)", "*** $1");
66  
67          // List subsubsubitem
68  
69          regexps.put("^\\t\\t\\t\\t[\\*] (.*)", "**** $1");
70  
71          // Ordered list item
72  
73          regexps.put("^\\t1 (.*)", "# $1");
74  
75          // Ordered list subitem
76  
77          regexps.put("^\\t\\t1 (.*)", "## $1");
78  
79          // Ordered list subsubitem
80  
81          regexps.put("^\\t\\t\\t1 (.*)", "### $1");
82  
83          // Ordered list subsubsubitem
84  
85          regexps.put("^\\t\\t\\t\\t1 (.*)", "#### $1");
86  
87          // Term and definition
88  
89          regexps.put("^\\t([\\w]+):\\t(.*)", "**$1**:\n$2");
90  
91          // Indented paragraph
92  
93          regexps.put("^\\t:\\t(.*)", "$1");
94  
95          // CamelCase
96  
97          regexps.put(
98              "(^|\\p{Punct}|\\p{Space})((\\p{Lu}\\p{Ll}+){2,})" +
99                  "(\\z|\\n|\\p{Punct}|\\p{Space})", " [[$2]] ");
100     }
101 
102 }