-
Notifications
You must be signed in to change notification settings - Fork 68
Add support for string unescape #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Mind rebasing pls? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for string unescaping and updates several parts of the codebase to use the new any type in place of interface{} while also refining number operations and filter definitions.
- Updated parser functions to accept a precompiled token matcher.
- Modified tests and filters to use int64 and any for improved consistency.
- Adjusted string unescaping logic to differentiate between single‐ and double‐quoted strings.
Reviewed Changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| parser/scanner.go | Updated Scan signature to accept tokenMatcher, ensuring callers supply a precompiled regular expression. |
| parser/parser_test.go & parser/parser.go | Updated Config instantiation to use NewConfig and pointer receivers for consistency. |
| parser/config.go | Introduced private delims and tokenMatcher fields along with a new Delims method. |
| liquid_test.go, engine_test.go, engine_examples_test.go | Replaced interface{} with any in test bindings to match new code conventions. |
| filters/standard_filters.go | Converted numeric filters to handle int64 values and adjusted filter logic for arithmetic operations. |
| expressions/* | Revised scanner and parser tests to expect int64 numeric values and improved string unescaping in double-quoted literals. |
| drops.go & drops_test.go | Updated Drop interface method return types to use any instead of interface{}. |
| if ia == 0 { | ||
| return math.NaN() | ||
| } | ||
| return math.Inf(int(ia)) |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using math.Inf(int(ia)) in the 'divided_by' filter introduces a mix of integer and floating-point return types. Consider standardizing the return type to float64 for division so that consumers consistently receive one numeric type.
| // TODO unescape \x | ||
| out.val = string(lex.data[lex.ts+1:lex.te-1]) | ||
| // unescape double quoted string | ||
| if lex.data[lex.ts] == '"' { |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Adding a comment here to clarify that only double-quoted strings are unescaped—while single-quoted strings are left intact—would improve code clarity for future maintainers.
- Added Unreleased section to CHANGELOG.md with recent features: - Jekyll Extensions Support (PR #114) - Auto-Escape Feature (PR #111) - Modernized Build Tooling (PR #115) - Added steve-ky as contributor for ideas/feedback on PR #89 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Updated CHANGELOG.md to include all merged PRs since version 1.3.0 (2020-02-13): Added features: - Jekyll Extensions Support (#114) - Auto-Escape Feature (#111) - Template Loader (#107) - BasicEngine (#104) - JSON Filter (#84) - Strict Variables Mode (#74) - Custom Writer Support (#86) - Template AST Access (#59, #66) - For-Else Support (#93) - Unless-Else Support (#68) - General Range Expressions (#65) - Loop Modifier Expressions (#67) Fixes: - Size filter, slice bounds, division by zero - Nil pointer handling - Whitespace control - Multiline slice - Block errors - Map filter with structs - And more Also added steve-ky as contributor for ideas/feedback on PR #89. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Checklist
make testpasses.make lintpasses.Support double quoted string unescape, single quoted string won't unescape.