Revert "[FEATURE] Support newlines and tabs in scripting strings (#1105)"
This reverts commit 80054aa77b.
This commit is contained in:
parent
3680f98a42
commit
49ea614fb2
3 changed files with 3 additions and 16 deletions
|
|
@ -301,14 +301,6 @@ class _Parser:
|
||||||
self._pos += len(str_open_token)
|
self._pos += len(str_open_token)
|
||||||
return String(value=string_value)
|
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
|
self._pos += 1
|
||||||
string_value += ch
|
string_value += ch
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,6 @@ class TestNumericFunctions:
|
||||||
("no splits", " | ", None, ["no splits"]),
|
("no splits", " | ", None, ["no splits"]),
|
||||||
("one | split", " | ", None, ["one", "split"]),
|
("one | split", " | ", None, ["one", "split"]),
|
||||||
("max | split | one", " | ", 1, ["max", "split | one"]),
|
("max | split | one", " | ", 1, ["max", "split | one"]),
|
||||||
("multiline\ndescription", "\\n", None, ["multiline", "description"]),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_split(
|
def test_split(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pytest
|
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_NOT_CLOSED
|
||||||
from ytdl_sub.script.parser import STRINGS_ONLY_ARGS
|
from ytdl_sub.script.parser import STRINGS_ONLY_ARGS
|
||||||
|
|
@ -46,13 +45,10 @@ class TestString:
|
||||||
("{%string('backslash \\\\')}", "backslash \\\\"),
|
("{%string('backslash \\\\')}", "backslash \\\\"),
|
||||||
("{%string('''triple quote with \" ' \\''')}", "triple quote with \" ' \\"),
|
("{%string('''triple quote with \" ' \\''')}", "triple quote with \" ' \\"),
|
||||||
('{%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):
|
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):
|
def test_null_is_empty_string(self):
|
||||||
assert Script({"out": "{%string(null)}"}).resolve() == ScriptOutput({"out": String("")})
|
assert Script({"out": "{%string(null)}"}).resolve() == ScriptOutput({"out": String("")})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue