Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 42111 | Differences between
and this patch

Collapse All | Expand All

(-)DocumentClass.py (-7 / +9 lines)
Lines 789-795 Link Here
789
789
790
    def doc_literal(
790
    def doc_literal(
791
        self, s,
791
        self, s,
792
        expr = re.compile(r"(\W+|^)'([%s%s%s\s]+)'([%s]+|$)" % (letters, digits, literal_punc, phrase_delimiters)).search,):
792
        expr = re.compile(r"(\W+|^)'((?:\w|[%s%s\s])+)'([%s]+|$)" % (digits, literal_punc, phrase_delimiters), re.U).search,):
793
793
794
        # old expr... failed to cross newlines.
794
        # old expr... failed to cross newlines.
795
        #        expr=re.compile(
795
        #        expr=re.compile(
Lines 807-813 Link Here
807
807
808
    def doc_emphasize(
808
    def doc_emphasize(
809
        self, s,
809
        self, s,
810
        expr = re.compile(r'\*([%s%s%s\s]+?)\*' % (letters, digits, strongem_punc)).search
810
        # i18nal variant
811
        expr = re.compile(r'\*((?:\w|[%s\s])+?)\*' % (strongem_punc), re.U).search
812
        #expr = re.compile(r'\*([%s%s%s\s]+?)\*' % (letters, digits, strongem_punc)).search
811
        #expr = re.compile(r'\s*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search       # old expr, inconsistent punctuation
813
        #expr = re.compile(r'\s*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search       # old expr, inconsistent punctuation
812
        ):
814
        ):
813
815
Lines 853-859 Link Here
853
855
854
    def doc_underline(self,
856
    def doc_underline(self,
855
                      s,
857
                      s,
856
                      expr=re.compile(r'_([%s%s%s\s]+)_([\s%s]|$)' % (letters, digits, under_punc,phrase_delimiters)).search):
858
                      expr=re.compile(r'_((?:\w|[%s\s])+)_([\s%s]|$)' % (under_punc,phrase_delimiters), re.U).search):
857
859
858
        result = expr(s)
860
        result = expr(s)
859
        if result:
861
        if result:
Lines 867-873 Link Here
867
869
868
    def doc_strong(self,
870
    def doc_strong(self,
869
                   s,
871
                   s,
870
                   expr = re.compile(r'\*\*([%s%s%s\s]+?)\*\*' % (letters, digits, strongem_punc)).search
872
                   expr = re.compile(r'\*\*((?:\w|[%s%s\s])+?)\*\*' % (digits, strongem_punc), re.U).search
871
                   #expr = re.compile(r'\s*\*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*\*(?!\*|-)' % letters).search, # old expr, inconsistent punc, failed to cross newlines.
873
                   #expr = re.compile(r'\s*\*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*\*(?!\*|-)' % letters).search, # old expr, inconsistent punc, failed to cross newlines.
872
        ):
874
        ):
873
875
Lines 879-885 Link Here
879
            return None
881
            return None
880
882
881
    ## Some constants to make the doc_href() regex easier to read.
883
    ## Some constants to make the doc_href() regex easier to read.
882
    _DQUOTEDTEXT = r'("[ %s0-9\n\r%s]+")' % (letters,dbl_quoted_punc) ## double quoted text
884
    _DQUOTEDTEXT = r'("[^"]+")'
883
    _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
885
    _ABSOLUTE_URL=r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
884
    _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
886
    _ABS_AND_RELATIVE_URL=r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%\+]+)' % letters
885
887
Lines 887-898 Link Here
887
889
888
890
889
    def doc_href1(self, s,
891
    def doc_href1(self, s,
890
                  expr=re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES).search
892
                  expr=re.compile(_DQUOTEDTEXT + "(:)" + _ABS_AND_RELATIVE_URL + _SPACES, re.U).search
891
                   ):
893
                   ):
892
        return self.doc_href(s, expr)
894
        return self.doc_href(s, expr)
893
895
894
    def doc_href2(self, s,
896
    def doc_href2(self, s,
895
                  expr=re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES).search
897
                  expr=re.compile(_DQUOTEDTEXT + r'(\,\s+)' + _ABSOLUTE_URL + _SPACES, re.U).search
896
                   ):
898
                   ):
897
        return self.doc_href(s, expr)
899
        return self.doc_href(s, expr)
898
900
(-)DocumentWithImages.py (-3 / +3 lines)
Lines 30-41 Link Here
30
30
31
    def doc_img(
31
    def doc_img(
32
        self, s,
32
        self, s,
33
        expr1=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)').search,
33
        expr1=re.compile('\"((?:\w|[ *.:/;,\-\n\~])+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)', re.U).search,
34
        expr2=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)').search
34
        expr2=re.compile('\"((?:\w|[ *.:/;,\-\n\~])+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)', re.U).search
35
        ):
35
        ):
36
37
        r = expr2(s)
36
        r = expr2(s)
38
        if r:
37
        if r:
38
39
39
40
            # Warning: the regex are getting confused when the string after :img:
40
            # Warning: the regex are getting confused when the string after :img:
41
            # is an URL containing ":" (Collector #2276)
41
            # is an URL containing ":" (Collector #2276)
(-)ST.py (+3 lines)
Lines 115-120 Link Here
115
    Structure => [paragraph,[sub-paragraphs]]
115
    Structure => [paragraph,[sub-paragraphs]]
116
    """
116
    """
117
117
118
    if type(paragraphs) == type(''):
119
        paragraphs = unicode(paragraphs, 'utf-8')
120
118
    currentlevel    = 0
121
    currentlevel    = 0
119
    currentindent  = 0
122
    currentindent  = 0
120
    levels            = {0:0}
123
    levels            = {0:0}
(-)tests/testStructuredText.py (-6 / +15 lines)
Lines 210-222 Link Here
210
        '<code>"literal":http://www.zope.org/.</code>')
210
        '<code>"literal":http://www.zope.org/.</code>')
211
211
212
212
213
    def XXXtestUnicodeContent(self):
213
    def testUnicodeContent(self):
214
        # This fails because ST uses the default locale to get "letters"
214
        self._test(u"h\xe9 **y\xe9** xx",
215
        # whereas it should use \w+ and re.U if the string is Unicode.
215
                   u"h\xe9 <strong>y\xe9</strong> xx")
216
        #self._test(u"h\xe9 **y\xe9** xx",
216
        self._test(u"h\xe9 *y\xe9* xx",
217
        #           u"h\xe9 <strong>y\xe9</strong> xx")
217
                   u"h\xe9 <em>y\xe9</em> xx")
218
        pass
218
        self._test(u"h\xe9 _y\xe9_ xx",
219
                   u"h\xe9 <u>y\xe9</u> xx")
220
        self._test(u"h\xe9 'y\xe9' xx",
221
                   u"h\xe9 <code>y\xe9</code> xx")
222
        self._test(u"h\xe9 \"y\xe9\":http://zope.org xx",
223
                   u"h\xe9 <a href=\"http://zope.org\">y\xe9</a> xx")
219
224
225
    def testDoNotHang(self):
226
        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.'
227
        res_txt = raw_str
228
        self._test(raw_str, res_txt)        
220
229
221
def test_suite():
230
def test_suite():
222
    suite = unittest.TestSuite()
231
    suite = unittest.TestSuite()

Return to bug 42111