Index: gc_core/js/lang_core/gc_engine.js ================================================================== --- gc_core/js/lang_core/gc_engine.js +++ gc_core/js/lang_core/gc_engine.js @@ -911,10 +911,15 @@ } else if (sWhat === "␣") { // merge tokens this.lTokens[nTokenRewriteStart]["nMergeUntil"] = nTokenRewriteEnd; } + else if (sWhat.startsWith("␣")) { + sWhat = this._expand(sWhat, nTokenOffset, nLastToken); + this.lTokens[nTokenRewriteStart]["nMergeUntil"] = nTokenRewriteEnd; + this.lTokens[nTokenRewriteStart]["sMergedValue"] = sWhat.slice(1); + } else if (sWhat === "_") { // neutralized token if (nTokenRewriteEnd - nTokenRewriteStart == 0) { this.lTokens[nTokenRewriteStart]["sNewValue"] = "_"; } else { @@ -981,10 +986,15 @@ if (bDebug) { console.log(" MERGED TOKEN: " + oMergingToken["sValue"]); } oToken["bMerged"] = true; bKeepToken = false; + if (iToken == nMergeUntil && oMergingToken.hasOwnProperty("sMergedValue")) { + oMergingToken["sValue"] = oMergingToken["sMergedValue"]; + let sSpaceFiller = " ".repeat(oToken["nEnd"] - oMergingToken["nStart"] - oMergingToken["sMergedValue"].length); + this.sSentence = this.sSentence.slice(0, oMergingToken["nStart"]) + oMergingToken["sMergedValue"] + sSpaceFiller + this.sSentence.slice(oToken["nEnd"]); + } } if (oToken.hasOwnProperty("nMergeUntil")) { if (iToken > nMergeUntil) { // this token is not already merged with a previous token oMergingToken = oToken; } Index: gc_core/py/lang_core/gc_engine.py ================================================================== --- gc_core/py/lang_core/gc_engine.py +++ gc_core/py/lang_core/gc_engine.py @@ -794,10 +794,14 @@ for i in range(nTokenRewriteStart, nTokenRewriteEnd+1): self.lTokens[i]["bToRemove"] = True elif sWhat == "␣": # merge tokens self.lTokens[nTokenRewriteStart]["nMergeUntil"] = nTokenRewriteEnd + elif sWhat.startswith("␣"): + sWhat = self._expand(sWhat, nTokenOffset, nLastToken) + self.lTokens[nTokenRewriteStart]["nMergeUntil"] = nTokenRewriteEnd + self.lTokens[nTokenRewriteStart]["sMergedValue"] = sWhat[1:] elif sWhat == "_": # neutralized token if nTokenRewriteEnd - nTokenRewriteStart == 0: self.lTokens[nTokenRewriteStart]["sNewValue"] = "_" else: @@ -846,10 +850,14 @@ dTokenMerger["nEnd"] = dToken["nEnd"] if bDebug: echo(" MERGED TOKEN: " + dTokenMerger["sValue"]) dToken["bMerged"] = True bKeepToken = False + if iToken == nMergeUntil and "sMergedValue" in dTokenMerger: + dTokenMerger["sValue"] = dTokenMerger["sMergedValue"] + sSpaceFiller = " " * (dToken["nEnd"] - dTokenMerger["nStart"] - len(dTokenMerger["sMergedValue"])) + self.sSentence = self.sSentence[:dTokenMerger["nStart"]] + dTokenMerger["sMergedValue"] + sSpaceFiller + self.sSentence[dToken["nEnd"]:] if "nMergeUntil" in dToken: # first token to be merge with if iToken > nMergeUntil: # this token is not to be merged with a previous token dTokenMerger = dToken if dToken["nMergeUntil"] > nMergeUntil: