From 49ea614fb24459af7bf5c0b997f882942f2c58c9 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sun, 27 Oct 2024 14:58:36 -0700 Subject: [PATCH] Revert "[FEATURE] Support newlines and tabs in scripting strings (#1105)" This reverts commit 80054aa77b84318b63396ea06453c2edefad6f13. --- src/ytdl_sub/script/parser.py | 12 ++---------- tests/unit/script/functions/test_string_functions.py | 1 - tests/unit/script/types/test_string.py | 6 +----- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/ytdl_sub/script/parser.py b/src/ytdl_sub/script/parser.py index 0f844e34..737d6ffa 100644 --- a/src/ytdl_sub/script/parser.py +++ b/src/ytdl_sub/script/parser.py @@ -301,16 +301,8 @@ class _Parser: self._pos += len(str_open_token) return String(value=string_value) - # Read literal "\n" as newlines - if self._read(increment_pos=False, length=2) == "\\n": - string_value += "\n" - self._pos += 2 - elif self._read(increment_pos=False, length=2) == "\\t": - string_value += "\t" - self._pos += 2 - else: - self._pos += 1 - string_value += ch + self._pos += 1 + string_value += ch raise STRINGS_NOT_CLOSED diff --git a/tests/unit/script/functions/test_string_functions.py b/tests/unit/script/functions/test_string_functions.py index ea3d441d..e5d898f8 100644 --- a/tests/unit/script/functions/test_string_functions.py +++ b/tests/unit/script/functions/test_string_functions.py @@ -132,7 +132,6 @@ class TestNumericFunctions: ("no splits", " | ", None, ["no splits"]), ("one | split", " | ", None, ["one", "split"]), ("max | split | one", " | ", 1, ["max", "split | one"]), - ("multiline\ndescription", "\\n", None, ["multiline", "description"]), ], ) def test_split( diff --git a/tests/unit/script/types/test_string.py b/tests/unit/script/types/test_string.py index 08700ace..c3749845 100644 --- a/tests/unit/script/types/test_string.py +++ b/tests/unit/script/types/test_string.py @@ -1,7 +1,6 @@ import re import pytest -from unit.script.conftest import single_variable_output from ytdl_sub.script.parser import STRINGS_NOT_CLOSED from ytdl_sub.script.parser import STRINGS_ONLY_ARGS @@ -46,13 +45,10 @@ class TestString: ("{%string('backslash \\\\')}", "backslash \\\\"), ("{%string('''triple quote with \" ' \\''')}", "triple quote with \" ' \\"), ('{%string("""triple quote with " \' \\""")}', "triple quote with \" ' \\"), - ("{%string('literal \\n newlines')}", "literal \n newlines"), - ("{%string('supports \t tabs')}", "supports \t tabs"), - ("{%string('literal \\t tabs')}", "literal \t tabs"), ], ) def test_string(self, string: str, expected_string: str): - assert single_variable_output(string) == expected_string + assert Script({"out": string}).resolve() == ScriptOutput({"out": String(expected_string)}) def test_null_is_empty_string(self): assert Script({"out": "{%string(null)}"}).resolve() == ScriptOutput({"out": String("")})