summaryrefslogtreecommitdiff
blob: 9cbf0ba65ee20d0f37dfb6052235f3f6180e4531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
? encode.diff
? i18n-0.9.9.patch
? i18n-1.0.0.patch
? i18n.patch
? run_tests
? test.diff
Index: ClassicStructuredText.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/ClassicStructuredText.py,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.1.2.1
diff -u -r1.1.1.2 -r1.1.1.1.2.1
Index: DocumentClass.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/DocumentClass.py,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 DocumentClass.py
--- DocumentClass.py	15 Apr 2003 15:13:52 -0000	1.1.1.1
+++ DocumentClass.py	9 Nov 2003 18:02:30 -0000
@@ -789,7 +789,7 @@
 
     def doc_literal(
         self, s,
-        expr = re.compile(r"(\W+|^)'([%s%s%s\s]+)'([%s]+|$)" % (letters, digits, literal_punc, phrase_delimiters)).search,):
+        expr = re.compile(r"(\W+|^)'((?:\w|[%s%s\s])+)'([%s]+|$)" % (digits, literal_punc, phrase_delimiters), re.U).search,):
 
         # old expr... failed to cross newlines.
         #        expr=re.compile(
@@ -807,7 +807,9 @@
 
     def doc_emphasize(
         self, s,
-        expr = re.compile(r'\*([%s%s%s\s]+?)\*' % (letters, digits, strongem_punc)).search
+        # i18nal variant
+        expr = re.compile(r'\*((?:\w|[%s\s])+?)\*' % (strongem_punc), re.U).search
+        #expr = re.compile(r'\*([%s%s%s\s]+?)\*' % (letters, digits, strongem_punc)).search
         #expr = re.compile(r'\s*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search       # old expr, inconsistent punctuation
         ):
 
@@ -853,7 +855,7 @@
 
     def doc_underline(self,
                       s,
-                      expr=re.compile(r'_([%s%s%s\s]+)_([\s%s]|$)' % (letters, digits, under_punc,phrase_delimiters)).search):
+                      expr=re.compile(r'_((?:\w|[%s\s])+)_([\s%s]|$)' % (under_punc,phrase_delimiters), re.U).search):
 
         result = expr(s)
         if result:
@@ -867,7 +869,7 @@
 
     def doc_strong(self,
                    s,
-                   expr = re.compile(r'\*\*([%s%s%s\s]+?)\*\*' % (letters, digits, strongem_punc)).search
+                   expr = re.compile(r'\*\*((?:\w|[%s%s\s])+?)\*\*' % (digits, strongem_punc), re.U).search
                    #expr = re.compile(r'\s*\*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*\*(?!\*|-)' % letters).search, # old expr, inconsistent punc, failed to cross newlines.
         ):
 
@@ -879,7 +881,7 @@
             return None
 
     ## Some constants to make the doc_href() regex easier to read.
-    _DQUOTEDTEXT = r'("[ %s0-9\n\r%s]+")' % (letters,dbl_quoted_punc) ## double quoted text
+    _DQUOTEDTEXT = r'("[^"]+")'
     _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
     _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
 
@@ -887,12 +889,12 @@
 
 
     def doc_href1(self, s,
-                  expr=re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES).search
+                  expr=re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES, re.U).search
                    ):
         return self.doc_href(s, expr)
 
     def doc_href2(self, s,
-                  expr=re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES).search
+                  expr=re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES, re.U).search
                    ):
         return self.doc_href(s, expr)
 
Index: DocumentWithImages.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/DocumentWithImages.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- DocumentWithImages.py	15 Apr 2003 15:13:52 -0000	1.1.1.1
+++ DocumentWithImages.py	15 Apr 2003 15:16:25 -0000	1.2
@@ -30,12 +30,12 @@
 
     def doc_img(
         self, s,
-        expr1=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)').search,
-        expr2=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)').search
+        expr1=re.compile('\"((?:\w|[ *.:/;,\-\n\~])+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)', re.U).search,
+        expr2=re.compile('\"((?:\w|[ *.:/;,\-\n\~])+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)', re.U).search
         ):
-
         r = expr2(s)
         if r:
+
 
             # Warning: the regex are getting confused when the string after :img:
             # is an URL containing ":" (Collector #2276)
Index: HTMLClass.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/HTMLClass.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2.2.2
diff -u -r1.1.1.1 -r1.2.2.2
Index: ST.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/ST.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- ST.py	15 Apr 2003 15:13:53 -0000	1.1.1.1
+++ ST.py	15 Apr 2003 15:16:25 -0000	1.2
@@ -115,6 +115,9 @@
     Structure => [paragraph,[sub-paragraphs]]
     """
 
+    if type(paragraphs) == type(''):
+        paragraphs = unicode(paragraphs, 'utf-8')
+
     currentlevel    = 0
     currentindent  = 0
     levels            = {0:0}
Index: Zwiki.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/Zwiki.py,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.1.2.1
diff -u -r1.1.1.2 -r1.1.1.1.2.1
Index: test.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/test.py,v
retrieving revision 1.1.1.1
retrieving revision 1.1.2.1
diff -u -r1.1.1.1 -r1.1.2.1
Index: tests/__init__.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/tests/__init__.py,v
retrieving revision 1.1.1.1
retrieving revision 1.1.2.1
diff -u -r1.1.1.1 -r1.1.2.1
Index: tests/testStructuredText.py
===================================================================
RCS file: /var/lib/cvs/nkm/zope/StructuredText/tests/testStructuredText.py,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.1 -r1.1.1.1.2.3
--- tests/testStructuredText.py	15 Apr 2003 15:13:56 -0000	1.1.1.1
+++ tests/testStructuredText.py	7 Nov 2003 12:12:32 -0000	1.1.1.1.2.3
@@ -210,13 +210,22 @@
         '<code>"literal":http://www.zope.org/.</code>')
 
 
-    def XXXtestUnicodeContent(self):
-        # This fails because ST uses the default locale to get "letters"
-        # whereas it should use \w+ and re.U if the string is Unicode.
-        #self._test(u"h\xe9 **y\xe9** xx",
-        #           u"h\xe9 <strong>y\xe9</strong> xx")
-        pass
+    def testUnicodeContent(self):
+        self._test(u"h\xe9 **y\xe9** xx",
+                   u"h\xe9 <strong>y\xe9</strong> xx")
+        self._test(u"h\xe9 *y\xe9* xx",
+                   u"h\xe9 <em>y\xe9</em> xx")
+        self._test(u"h\xe9 _y\xe9_ xx",
+                   u"h\xe9 <u>y\xe9</u> xx")
+        self._test(u"h\xe9 'y\xe9' xx",
+                   u"h\xe9 <code>y\xe9</code> xx")
+        self._test(u"h\xe9 \"y\xe9\":http://zope.org xx",
+                   u"h\xe9 <a href=\"http://zope.org\">y\xe9</a> xx")
 
+    def testDoNotHang(self):
+        raw_str = 'UAB "Vita Baltic International" produkcijos asortiment\u0105 papild\u0117 dar trys  specifines nedegumo savybes turin\u010dios porolono ru\u0161ys. \nSpalio m\u0117nes\u012f buvo gauti tarptautiniai sertifikatai, liudijantys, kad porolonai CV 3037, CV 3538 ir CV 2533 atitinka degumo standart\u0173 BS 5852:Part 2: 1982 reikalavimus. Tai labai gera \u017einia bald\u0173 gamintojams, gaminantiems baldus ir \u010diu\u017einius,\nkuri\u0173 gaminiams keliami ypatingi importuotoj\u0173 reikalavimai.'
+        res_txt = raw_str
+        self._test(raw_str, res_txt)        
 
 def test_suite():
     suite = unittest.TestSuite()