summaryrefslogtreecommitdiff
path: root/www/zope213/files/patch-lib-python-zope-structuredtext
blob: 1ab065bf490ba11dd9203f9b8f628562e14c88f2 (plain) (blame)
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
--- lib/python/zope/structuredtext/document.py.orig	Thu Nov 23 16:54:41 2006
+++ lib/python/zope/structuredtext/document.py	Thu Nov 23 17:14:20 2006
@@ -556,7 +556,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,):
         r = expr(s)
         if r:
             start, end = r.span(2)
@@ -564,7 +564,8 @@
 
     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
         ):
 
         r=expr(s)
@@ -605,7 +606,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:
@@ -617,7 +618,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.
         ):
 
@@ -627,19 +628,19 @@
             return (stng.StructuredTextStrong(s[start:end]), start-2, end+2)
 
     ## 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'("[^"]+")'  ## double quoted text
     _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
     _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
 
     _SPACES = r'(\s*)'
 
     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)
 
@@ -693,7 +694,7 @@
 
     def doc_img(
         self, s,
-        expr1=re.compile('\"([ _a-zA-Z0-9*.:/;,\[\]\'\-\n\~]+)\":img:([a-zA-Z0-9%\_\-.:/\?=;,\n\~]+)').search,
+        expr1=re.compile('\"((?:\w|[ *.:/;,\-\n\~])+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)', re.U).search,
         ):
 
         r=expr1(s)
--- lib/python/zope/structuredtext/stng.py.orig	Thu Nov 23 17:00:38 2006
+++ lib/python/zope/structuredtext/stng.py	Thu Nov 23 17:02:45 2006
@@ -105,6 +105,9 @@
     [paragraph,[sub-paragraphs]]
     """
 
+    if type(paragraphs) == type(''):
+        paragraphs = unicode(paragraphs, 'utf-8')
+
     currentlevel   = 0
     currentindent  = 0
     levels         = {0:0}