diff options
author | László Németh <nemeth@numbertext.org> | 2018-10-26 10:58:47 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2018-10-26 15:51:58 +0200 |
commit | 5590c70b47c029006edec41be70c34a0a07fd6fd (patch) | |
tree | 8bb8d199f899fdfc7e12deeb057d66130d02b3b7 /librelogo | |
parent | 06599d1f670516ce97267d746fa230a0c9310f3d (diff) |
LibreLogo: support backslash escape sequence for apostrophes
(ASCII and typographical) and for enclosing quotes of string literals.
Change-Id: I3caf3b707afa1fb41ba3afe9ff12ebce7ce63847
Reviewed-on: https://gerrit.libreoffice.org/62384
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'librelogo')
-rw-r--r-- | librelogo/source/LibreLogo/LibreLogo.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index 8834baf8e640..626c5d210f09 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -417,7 +417,7 @@ def __translate__(arg = None): __strings__ = [] text = re.sub(r"^(([ \t]*[;#][^\n]*))", __encodecomment__, text) - text = re.sub("(?u)([%s])([^\n%s]*)(?<!\\\\)[%s]" % (lq, rq, rq), __encodestring__, selection.getString()) + text = re.sub("(?u)([%s])((?:[^\n%s]|\\\\[%s])*)(?<!\\\\)[%s]" % (lq, rq, rq, rq), __encodestring__, selection.getString()) text = re.sub('(?u)(?<![0-9])(")(~?\w*)', __encodestring__, text) text = re.sub(r";(([^\n]*))", __encodecomment__, text) @@ -521,7 +521,8 @@ def __is_alive__(): return __thread__ != None def __encodestring__(m): - __strings__.append(re.sub("\\[^\\]", "", m.group(2))) + __strings__.append(re.sub("(\\[^\\]|\\\\(?=[‘’“”»」』]))", "", m.group(2))) + # replace the string with the numbered identifier _s_0___, _s_1___, ... return __ENCODED_STRING__ % (len(__strings__) - 1) def __encodecomment__(m): @@ -1767,7 +1768,7 @@ def __compil__(s): lq = '\'' + __l12n__(_.lng)['LEFTSTRING'].replace("|", "") rq = '\'' + __l12n__(_.lng)['RIGHTSTRING'].replace("|", "") __strings__ = [] - s = re.sub("(?u)([%s])([^\n%s]*)(?<!\\\\)[%s]" % (lq, rq, rq), __encodestring__, s) + s = re.sub("(?u)([%s])((?:[^\n%s]|\\\\[%s])*)(?<!\\\\)[%s]" % (lq, rq, rq, rq), __encodestring__, s) s = re.sub('(?u)(?<![0-9])(")(~?\w*)', __encodestring__, s) # remove extra spaces |