Grammalecte  Check-in [86c9c40cab]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[core] gc engine: new operator (@) for regex text processor
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core
Files: files | file ages | folders
SHA3-256:86c9c40cab4be357c1f6169ef80c17b19539ba42a3ddc8265e17e11588bf9213
User & Date: olr 2019-01-02 12:56:09
Context
2019-01-02
13:58
[fr] html: purge des espaces insécables fins check-in: 0e847b75ad user: olr tags: fr, trunk
12:56
[core] gc engine: new operator (@) for regex text processor check-in: 86c9c40cab user: olr tags: core, trunk
12:55
[fr] nr: de sorte que, +ajustements divers check-in: 136beb2dc6 user: olr tags: fr, trunk
Changes

Changes to gc_core/js/lang_core/gc_engine.js.

   229    229           }
   230    230           if (this.sText.includes("'")) {
   231    231               this.sText = this.sText.replace(/'/g, "’");
   232    232           }
   233    233           if (this.sText.includes("‑")) {
   234    234               this.sText = this.sText.replace(/‑/g, "-"); // nobreakdash
   235    235           }
          236  +        if (this.sText.includes("@@")) {
          237  +            this.sText = this.sText.replace(/@@+/g, "");
          238  +        }
   236    239   
   237    240           // parse sentence
   238    241           for (let [iStart, iEnd] of gc_engine.getSentenceBoundaries(this.sText)) {
   239    242               try {
   240    243                   this.sSentence = this.sText.slice(iStart, iEnd);
   241    244                   this.sSentence0 = this.sText0.slice(iStart, iEnd);
   242    245                   this.nOffsetWithinParagraph = iStart;
................................................................................
   793    796       rewriteText (sText, sRepl, iGroup, m, bUppercase) {
   794    797           // text processor: write sRepl in sText at iGroup position"
   795    798           let ln = m.end[iGroup] - m.start[iGroup];
   796    799           let sNew = "";
   797    800           if (sRepl === "*") {
   798    801               sNew = " ".repeat(ln);
   799    802           }
   800         -        else if (sRepl === ">" || sRepl === "_" || sRepl === "~") {
   801         -            sNew = sRepl + " ".repeat(ln-1);
          803  +        else if (sRepl === "_") {
          804  +            sNew = "_".repeat(ln);
   802    805           }
   803    806           else if (sRepl === "@") {
   804    807               sNew = "@".repeat(ln);
   805    808           }
   806    809           else if (sRepl.slice(0,1) === "=") {
   807    810               sNew = oEvalFunc[sRepl.slice(1)](sText, m);
   808    811               sNew = sNew + " ".repeat(ln-sNew.length);

Changes to gc_core/py/lang_core/gc_engine.py.

   258    258               sText = sText.replace(" ", ' ') # nbsp
   259    259           if " " in sText:
   260    260               sText = sText.replace(" ", ' ') # nnbsp
   261    261           if "'" in sText:
   262    262               sText = sText.replace("'", "’")
   263    263           if "‑" in sText:
   264    264               sText = sText.replace("‑", "-") # nobreakdash
          265  +        if "@@" in sText:
          266  +            sText = re.sub("@@+", "", sText)
   265    267   
   266    268           # parse sentences
   267    269           for iStart, iEnd in _getSentenceBoundaries(sText):
   268    270               if 4 < (iEnd - iStart) < 2000:
   269    271                   try:
   270    272                       self.sSentence = sText[iStart:iEnd]
   271    273                       self.sSentence0 = self.sText0[iStart:iEnd]
................................................................................
   685    687   
   686    688       def rewriteText (self, sText, sRepl, iGroup, m, bUppercase):
   687    689           "text processor: write <sRepl> in <sText> at <iGroup> position"
   688    690           nLen = m.end(iGroup) - m.start(iGroup)
   689    691           if sRepl == "*":
   690    692               sNew = " " * nLen
   691    693           elif sRepl == "_":
   692         -            sNew = sRepl + " " * (nLen-1)
          694  +            sNew = "_" * nLen
          695  +        elif sRepl == "@":
          696  +            sNew = "@" * nLen
   693    697           elif sRepl[0:1] == "=":
   694    698               sNew = globals()[sRepl[1:]](sText, m)
   695    699               sNew = sNew + " " * (nLen-len(sNew))
   696    700               if bUppercase and m.group(iGroup)[0:1].isupper():
   697    701                   sNew = sNew.capitalize()
   698    702           else:
   699    703               sNew = m.expand(sRepl)