From 7182b0bbd906b6d656eee26cd0f3afa39388c08d Mon Sep 17 00:00:00 2001 From: yasuda Date: Wed, 21 May 2025 17:05:17 +0900 Subject: [PATCH] Fix token handling with separator `<`, `>`, `+` --- sparkup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sparkup.py b/sparkup.py index b545df2..6e8efba 100755 --- a/sparkup.py +++ b/sparkup.py @@ -446,7 +446,12 @@ def _tokenize(self): str = str[:-len(match[0])] # Split by the element separators - for token in re.split('(<|>|\+(?!\\s*\+|$))', str): + tokens = re.split(r'(<|>|\+(?!\\s*\+|$))', str) + for i in range(0, len(tokens) - 1): + while i < len(tokens) - 1 and re.search(r'\[[^\]]*$|\{[^\}]*$', tokens[i]): + tokens[i] += tokens[i+1] + tokens.pop(i+1) + for token in tokens: if token.strip() != '': self.tokens.append(Token(token, parser=self))