Grammalecte  Check-in [001f5897d2]

Overview
Comment:[fr][bug] formateur de texte: URL
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fr
Files: files | file ages | folders
SHA3-256: 001f5897d2ed9552804d6c59d056f9724b719945651578374dd064083d921f80
User & Date: olr on 2017-06-27 08:49:05
Other Links: manifest | tags
Context
2017-06-27
13:38
[fr][oxt] formateur de texte: table de remplacement séparée check-in: 58cdb431b8 user: olr tags: trunk, fr
08:49
[fr][bug] formateur de texte: URL check-in: 001f5897d2 user: olr tags: trunk, fr
2017-06-26
08:45
[fr] + 2 tests check-in: 0ff766161c user: olr tags: trunk, fr
Changes

Modified gc_lang/fr/modules-js/textformatter.js from [694a6a3f2d] to [fcd9e4b1a6].

60
61
62
63
64
65
66
67

68
69
70
71
72
73
74
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74







-
+







    "nbsp_repair":                [ [/([\[(])[   ]([!?:;])/g, "$1$2"],
                                    [/(https?|ftp)[   ]:\/\//g, "$1://"],
                                    [/&([a-z]+)[   ];/g, "&$1;"],
                                    [/&#([0-9]+|x[0-9a-fA-F]+)[   ];/g, "&#$1;"] ],
    //// missing spaces
    "add_space_after_punctuation":[ [/[;!…](?=[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ])/g, "$& "],
                                    [/[?](?=[A-ZÀ-ÖØ-ßĀ-ʯ])/g, "? "],
                                    [/\.(?=[a-zA-Zà-öÀ-Öø-ÿØ-ßĀ-ʯ][a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ])/g, ". "],
                                    [/\.(?=[A-ZÀ-ÖØ-ßĀ-ʯ][a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ])/g, ". "],
                                    [/\.(?=À)/g, ". "],
                                    [/[,:](?=[a-zA-Zà-öÀ-Öø-ÿØ-ßĀ-ʯ])/g, "$& "],
                                    [/([a-zA-Zà-öÀ-Öø-ÿØ-ßĀ-ʯ]),(?=[0-9])/g, "$1, "] ],
    "add_space_around_hyphens":   [ [/ [-–—](?=[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ"«“'‘])/g, "$& "],
                                    [/([a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ"»”'’])([-–—]) /g, "$1 $2 "] ],
    "add_space_repair":           [ [/DnT, ([wA])\b/g, "DnT,$1"] ],
    //// erase

Modified gc_lang/fr/oxt/TextFormatter/TextFormatter.py from [32ab9b6099] to [63b9caa31e].

421
422
423
424
425
426
427

428
429
430
431
432
433
434
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435







+







            # change pointer
            xPointer = self.ctx.ServiceManager.createInstanceWithContext("com.sun.star.awt.Pointer", self.ctx)
            xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.WAIT"))
            xWindowPeer = self.xContainer.getPeer()
            xWindowPeer.setPointer(xPointer)
            for x in xWindowPeer.Windows:
                x.setPointer(xPointer)
            # ICU: & is $0 in replacement field
            # NOTE: A LOT OF REGEX COULD BE MERGED IF ICU ENGINE WAS NOT SO BUGGY
            # "([;?!…])(?=[:alnum:])" => "$1 " doesn’t work properly
            # "(?<=[:alnum:])([;?!…])" => " $1 " doesn’t work properly
            self.pbar.ProgressValue = 0
            # Restructuration
            if self.struct.State:
                if self.struct1.State:
514
515
516
517
518
519
520

521
522
523
524
525
526
527
528
529
530
531







532
533
534
535
536
537
538
515
516
517
518
519
520
521
522
523
524
525
526







527
528
529
530
531
532
533
534
535
536
537
538
539
540







+




-
-
-
-
-
-
-
+
+
+
+
+
+
+







                        n += self._replaceText(xElem, "(?<=[:alnum:])!", " !", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}]):", " :", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}]);", " ;", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])[?][   ]", " ? ", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])[?]$", " ?", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])!", " !", True)
                        n += self._replaceText(xElem, "[  ]+([:;?!])", " $1", True)
                    # réparations
                    n -= self._replaceText(xElem, "([[(])[   ]([!?:;])", "$1$2", True)
                    n -= self._replaceText(xElem, "(?<=http)[   ]://", "://", True)
                    n -= self._replaceText(xElem, "(?<=https)[   ]://", "://", True)
                    n -= self._replaceText(xElem, "(?<=ftp)[   ]://", "://", True)
                    n -= self._replaceText(xElem, "(?<=&)amp[   ];", "amp;", True)          # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)nbsp[   ];", "nbsp;", True)        # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)lt[   ];", "lt;", True)            # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)gt[   ];", "gt;", True)            # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)apos[   ];", "apos;", True)        # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)quot[   ];", "quot;", True)        # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)thinsp[   ];", "thinsp;", True)    # ICU: & is $0 in replacement field
                    n -= self._replaceText(xElem, "(?<=&)amp[   ];", "amp;", True)          
                    n -= self._replaceText(xElem, "(?<=&)nbsp[   ];", "nbsp;", True)
                    n -= self._replaceText(xElem, "(?<=&)lt[   ];", "lt;", True)
                    n -= self._replaceText(xElem, "(?<=&)gt[   ];", "gt;", True)
                    n -= self._replaceText(xElem, "(?<=&)apos[   ];", "apos;", True)
                    n -= self._replaceText(xElem, "(?<=&)quot[   ];", "quot;", True)
                    n -= self._replaceText(xElem, "(?<=&)thinsp[   ];", "thinsp;", True)
                    self.nbsp1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp2.State:
                    if self.nnbsp2.State:
                        # espaces insécables fines
                        n = self._replaceText(xElem, "«(?=[:alnum:])", "« ", True)
                        n += self._replaceText(xElem, "«[  ]+", "« ", True)
567
568
569
570
571
572
573
574

575
576
577
578
579
580
581
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583







-
+







                if False:
                    n = self._replaceText(xElem, "\\b(MM?\\.|Mlle|Mgr) ", "$1 ", True)
                    self.nbsp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.nbsp.State = False
                self._switchCheckBox(self.nbsp)
            self.pbar.ProgressValue = 15
            # espaces manquants
            # points médians
            if self.typo.State:
                if self.typo6.State:
                    n = self._replaceText(xElem, "\\bN\\.([ms])\\b", "N·$1", True, True) # N·m et N·m-1, N·s
                    n += self._replaceText(xElem, "\\bW\\.h\\b", "W·h", True, True)
                    n += self._replaceText(xElem, "\\bPa\\.s\\b", "Pa·s", True, True)
                    n += self._replaceText(xElem, "\\bA\\.h\\b", "A·h", True, True)
                    n += self._replaceText(xElem, "\\bΩ\\.m\\b", "Ω·m", True, True)
595
596
597
598
599
600
601

602
603
604
605

606
607
608
609
610
611
612
613

614
615
616
617
618
619
620
597
598
599
600
601
602
603
604
605
606
607

608
609
610
611
612
613
614
615

616
617
618
619
620
621
622
623







+



-
+







-
+







                    n += self._replaceText(xElem, "\\bm[3³]\\.s(?=-1)\\b", "m³·s", True, True)
                    #n += self._replaceText(xElem, "\\bJ.kg-1.K-1\\b", "J·kg-1·K-1", True, True)
                    #n += self._replaceText(xElem, "\\bW.m-1.K-1\\b", "W·m-1·K-1", True, True)
                    #n += self._replaceText(xElem, "\\bW.m-2.K-1\\b", "W·m-2·K-1", True, True)
                    n += self._replaceText(xElem, "\\b(Y|Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)Ω\\b", "$1Ω", True, True)
                    self.typo6_res.Label = str(n)
                    self.pbar.ProgressValue += 1
            # espaces manquants
            if self.space.State:
                if self.space1.State:
                    n = self._replaceText(xElem, ";(?=[:alnum:])", "; ", True)
                    n += self._replaceText(xElem, "\\?(?=[A-ZÉÈÊÂÀÎ])", "? ", True)
                    n += self._replaceText(xElem, "\\?(?=[A-ZÉÈÊÂÀÎ])", "? ", True, True)
                    n += self._replaceText(xElem, "!(?=[:alnum:])", "! ", True)
                    n += self._replaceText(xElem, "…(?=[:alnum:])", "… ", True)
                    n += self._replaceText(xElem, "\\.(?=[A-ZÉÈÎ][:alpha:])", ". ", True, True)
                    n += self._replaceText(xElem, "\\.(?=À)", ". ", True, True)
                    n += self._replaceText(xElem, ",(?=[:alpha:])", ", ", True)
                    n += self._replaceText(xElem, "([:alpha:]),([0-9])", "$1, $2", True)
                    n += self._replaceText(xElem, ":(?=[:alpha:])", ": ", True)
                    # exceptions:
                    # réparations
                    n -= self._replaceText(xElem, "(?<=DnT), w\\b", ",w", True, True)
                    n -= self._replaceText(xElem, "(?<=DnT), A\\b", ",A", True, True)
                    self.space1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.space2.State:
                    n = self._replaceText(xElem, " -(?=[:alpha:]|[\"«“'‘])", " - ", True)
                    n += self._replaceText(xElem, " –(?=[:alpha:]|[\"«“'‘])", " – ", True) # demi-cadratin