From aa581b040ff3e75d2e13c49eae6325027ff99527 Mon Sep 17 00:00:00 2001 From: Tom Fryers <61272761+TomFryers@users.noreply.github.com> Date: Thu, 17 Sep 2020 13:04:37 +0100 Subject: [PATCH 1/2] Allow escaped spaces in ArrayListSpaceSeperated Uses \s to represent a space. If a literal \s is required, \\s can be used. In particular this allows [ ] as a todo keyword. --- .../com/orgzly/org/utils/ArrayListSpaceSeparated.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java b/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java index ad63279..f044ddf 100644 --- a/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java +++ b/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java @@ -13,7 +13,7 @@ public ArrayListSpaceSeparated() { public ArrayListSpaceSeparated(String str) { for (String s: str.split(DELIMITER)) { - String st = s.trim(); + String st = s.trim().replace("\s", " ").replace("\ ", "\s"); if (st.length() > 0) { add(st); } @@ -21,6 +21,10 @@ public ArrayListSpaceSeparated(String str) { } public String toString() { - return OrgStringUtils.join(this, DELIMITER); + String str = ""; + for (String s: this) { + str += s.replace("\s", "\\s").replace(" ", "\s") + " "; + } + return str.substring(0, str.length() - 1); } } From 5bca63f686654d220a9f3d4068a45e2b73d4ce37 Mon Sep 17 00:00:00 2001 From: Tom Fryers Date: Thu, 17 Sep 2020 13:12:05 +0100 Subject: [PATCH 2/2] Fix escape sequences --- .../java/com/orgzly/org/utils/ArrayListSpaceSeparated.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java b/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java index f044ddf..63ea5da 100644 --- a/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java +++ b/src/main/java/com/orgzly/org/utils/ArrayListSpaceSeparated.java @@ -13,7 +13,7 @@ public ArrayListSpaceSeparated() { public ArrayListSpaceSeparated(String str) { for (String s: str.split(DELIMITER)) { - String st = s.trim().replace("\s", " ").replace("\ ", "\s"); + String st = s.trim().replace("\\s", " ").replace("\\ ", "\\s"); if (st.length() > 0) { add(st); } @@ -23,7 +23,7 @@ public ArrayListSpaceSeparated(String str) { public String toString() { String str = ""; for (String s: this) { - str += s.replace("\s", "\\s").replace(" ", "\s") + " "; + str += s.replace("\\s", "\\\\s").replace(" ", "\\s") + " "; } return str.substring(0, str.length() - 1); }