fix bug
This commit is contained in:
10
KAGParser.py
10
KAGParser.py
@@ -78,8 +78,9 @@ class TagNode(INode):
|
|||||||
parts.append(key)
|
parts.append(key)
|
||||||
else:
|
else:
|
||||||
val_str = str(value)
|
val_str = str(value)
|
||||||
# Quote the value if it contains spaces to ensure it's parsed correctly.
|
# Quote the value if it contains spaces (ASCII or full-width)
|
||||||
if " " in val_str or "=" in val_str:
|
# to ensure it's parsed correctly on round-trip.
|
||||||
|
if " " in val_str or "\u3000" in val_str or "=" in val_str:
|
||||||
parts.append(f'{key}="{val_str}"')
|
parts.append(f'{key}="{val_str}"')
|
||||||
else:
|
else:
|
||||||
parts.append(f"{key}={val_str}")
|
parts.append(f"{key}={val_str}")
|
||||||
@@ -134,6 +135,9 @@ class KAGScriptParser:
|
|||||||
|
|
||||||
# Regex to parse attributes within a tag/command string.
|
# Regex to parse attributes within a tag/command string.
|
||||||
# It handles: key=value, key="value", key='value', and boolean keys.
|
# It handles: key=value, key="value", key='value', and boolean keys.
|
||||||
|
# Note: Only ASCII whitespace (space, tab) is treated as an attribute
|
||||||
|
# separator. Unicode whitespace such as U+3000 (full-width space) is
|
||||||
|
# preserved as part of an unquoted value.
|
||||||
_ATTR_RE = re.compile(
|
_ATTR_RE = re.compile(
|
||||||
r"""
|
r"""
|
||||||
([a-zA-Z0-9_]+) # Attribute key
|
([a-zA-Z0-9_]+) # Attribute key
|
||||||
@@ -142,7 +146,7 @@ class KAGScriptParser:
|
|||||||
(
|
(
|
||||||
"[^"]*" | # Double-quoted value
|
"[^"]*" | # Double-quoted value
|
||||||
'[^']*' | # Single-quoted value
|
'[^']*' | # Single-quoted value
|
||||||
[^\s\]]+ # Unquoted value
|
[^ \t\]]+ # Unquoted value (no ASCII space, tab, or ']')
|
||||||
)
|
)
|
||||||
)? # The entire value part is optional
|
)? # The entire value part is optional
|
||||||
""",
|
""",
|
||||||
|
|||||||
Reference in New Issue
Block a user