From 6ede6152b183d2f9c454b62283c4f16106d27429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Simi=C4=87?= Date: Sat, 24 Aug 2024 01:43:50 +0200 Subject: [PATCH 1/2] Test for multiline object properties. --- tests/test_tiled_object_tmx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_tiled_object_tmx.py b/tests/test_tiled_object_tmx.py index 702ced32..9b6a3848 100644 --- a/tests/test_tiled_object_tmx.py +++ b/tests/test_tiled_object_tmx.py @@ -129,6 +129,9 @@ + Hi +I can write multiple lines in here +That's pretty great """, @@ -144,6 +147,7 @@ "float property": 42.1, "int property": 8675309, "string property": "pytiled_parser rulez!1!!", + "multiline string property": "Hi\nI can write multiple lines in here\nThat's pretty great", }, ), ), From 356723cdd98dc2cfedffc405897e4c25d3e84612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Simi=C4=87?= Date: Sat, 24 Aug 2024 01:44:28 +0200 Subject: [PATCH 2/2] Fix parsing of multiline string properties. --- pytiled_parser/parsers/tmx/properties.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pytiled_parser/parsers/tmx/properties.py b/pytiled_parser/parsers/tmx/properties.py index 1b20e3d4..2c6f7dc4 100644 --- a/pytiled_parser/parsers/tmx/properties.py +++ b/pytiled_parser/parsers/tmx/properties.py @@ -12,11 +12,10 @@ def parse(raw_properties: etree.Element) -> Properties: for raw_property in raw_properties.findall("property"): type_ = raw_property.attrib.get("type") - if "value" not in raw_property.attrib: + value_ = raw_property.attrib.get("value", raw_property.text) + if value_ is None: continue - value_ = raw_property.attrib["value"] - if type_ == "file": value = Path(value_) elif type_ == "color":