diff --git a/tests/test_everything.yaml b/tests/test_everything.yaml index 4a6a3c3..d823162 100644 --- a/tests/test_everything.yaml +++ b/tests/test_everything.yaml @@ -129,3 +129,7 @@ complex_anchor_chains: final: <<: *derived2 # Final merge final: value3 + +# Complex string +config: + where: '{{ "my_column != date ''2025-08-31''" if target.name == ''prod'' else ''1=1'' }}' diff --git a/yamlium/lexer.py b/yamlium/lexer.py index 5b8dd1d..4730b03 100644 --- a/yamlium/lexer.py +++ b/yamlium/lexer.py @@ -393,7 +393,18 @@ def _parse_quoted_scalar(self) -> list[Token]: quote_char = self.c self._nc() char = self.c - while char != quote_char: + while True: + if char == quote_char: + # Check if this is an escaped quote (two consecutive quotes) + if quote_char == "'" and self.c_future == "'": + # Skip both quotes - this is an escaped single quote + self._nc() # Skip first quote + self._nc() # Skip second quote + char = self.c + continue + else: + # Found the closing quote + break if char == "\n": # In YAML, quoted strings can span multiple lines # Track the newline for proper line/column tracking