Correct text identification in liquid syntax#19489
Conversation
commit: |
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| Braces | ||
| {% doesn't match so these words should not be considered as *liquid node* }} | ||
| Braces {% doesn't match so these words should not be considered as _liquid node_ | ||
| }} |
There was a problem hiding this comment.
My bad, these cases were treated as liquid and I missed this problem regardless of what the cases mention...
|
Not sure how it works exactly, but thanks! Should we add more tests? Prettier v3.9.1 --parser markdownInput: {{% blocks/cover
%}}
{{% blocks/cover
%%}}
{{% blocks/cover
}}}
{{{% blocks/cover
%}}
{% blocks/cover
%}}
{{ blocks/cover
%}}
Output: {{% blocks/cover
}
{{% blocks/cover
}
{{% blocks/cover
}
{{{% blocks/cover
}
{% blocks/cover
}
{{ blocks/cover
}
|
|
@fisker Yes, we definitely need to add tests. I found that other problematic inputs and this branch doesn't fix them yet. Still tackling it. I'll also add tests you suggest. |
| function exit(token) { | ||
| const d = this.resume(); | ||
| this.resume(); | ||
| /** @type {any} */ | ||
| const node = this.stack.at(-1); | ||
| node.value = d; | ||
| node.value = this.sliceSerialize(token); | ||
| this.exit(token); | ||
| } |
There was a problem hiding this comment.
Only change in this function is the core fix for the problem 3061abd.
Other changes are minor improvement:
- 1805553: match opening/closing tokens. It can accidentally fix the input reported in [3.9 regression] Markdown: multi-line
{{% … %}}shortcode corrupted — standalone%}}line rewritten to}#19488. - 39c1f88: refactoring. use of
effects.checkwas overengineering.
|
I'm not familiar with micromark plugins, but are we making the plugin complex? The first version is so simple... 7bc5ec2 |
|
We should rename the type |
Yes, in a sense. And it's because extension API change. AFAIK, micromark requires state machine style to implement extensions. It's the standard way at least. Maybe it provides reliable implementation for complex syntax as it resolves many parser issues. And it requires its specific knowledges even for simple extensions instead. |
| {{ page.title | ||
| }} text |
There was a problem hiding this comment.
This might not look related to #19488, but this input points serious issue.
If it's just a open/close mismatch issue, it should had to emit correct result, {{% ... %} + }.
The serious point is that it omitted part of liquid node when multi-line + following character after closing tokens.
fisker
left a comment
There was a problem hiding this comment.
Thank you for your great work as always!
|
|
|
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [prettier](https://prettier.io) ([source](https://github.com/prettier/prettier)) | [`3.8.5` → `3.9.4`](https://renovatebot.com/diffs/npm/prettier/3.8.5/3.9.4) |  |  | --- ### Release Notes <details> <summary>prettier/prettier (prettier)</summary> ### [`v3.9.4`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#394) [Compare Source](prettier/prettier@3.9.3...3.9.4) [diff](prettier/prettier@3.9.3...3.9.4) ##### Angular: Format `@content(name)` -> `@content (name)` to align with other block syntax ([#​19499](prettier/prettier#19499) by [@​fisker](https://github.com/fisker)) <!-- prettier-ignore --> ```html <!-- Input --> <FancyButton [label]="title"> @​content (icon) { <span>Icon!</span> } @​content (description) { <span>Description text</span> } <span>Other children</span> </FancyButton> <!-- Prettier 3.9.3 --> <FancyButton [label]="title"> @​content(icon) { <span>Icon!</span> } @​content(description) { <span>Description text</span> } <span>Other children</span> </FancyButton> <!-- Prettier 3.9.4 --> <FancyButton [label]="title"> @​content (icon) { <span>Icon!</span> } @​content (description) { <span>Description text</span> } <span>Other children</span> </FancyButton> ``` ### [`v3.9.3`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#393) [Compare Source](prettier/prettier@3.9.2...3.9.3) [diff](prettier/prettier@3.9.1...3.9.3) ##### Markdown: Fix unexpected removal of characters in liquid syntax ([#​19489](prettier/prettier#19489) by [@​seiyab](https://github.com/seiyab)) <!-- prettier-ignore --> ```md // Input <!-- Input --> {{ page.title }} text <!-- Prettier 3.9.1 --> {{ page.title text <!-- Prettier 3.9.3 --> {{ page.title }} text ``` ##### TypeScript: Allow decorators to be used with declare on class fields ([#​19492](prettier/prettier#19492) by [@​evoactivity](https://github.com/evoactivity)) Extensively used within the Ember ecosystem, decorators with `declare` on class fields will ignore the babel parser error and allow Prettier to format the code without breaking it. <!-- prettier-ignore --> ```ts // Input export default class ProjectStatusComponent extends Component<ProjectStatusSig> { @​service declare server: ServerService; } // Prettier 3.9.1 // SyntaxError: Decorators can't be used with a declare field. (2:3) // 1 | export default class ProjectStatusComponent extends Component<ProjectStatusSig> { //> 2 | @​service declare server: ServerService; // | ^ // 3 | } // Prettier 3.9.3 export default class ProjectStatusComponent extends Component<ProjectStatusSig> { @​service declare server: ServerService; } ``` ### [`v3.9.2`](prettier/prettier@3.9.1...3.9.2) [Compare Source](prettier/prettier@3.9.1...3.9.2) ### [`v3.9.1`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#391) [Compare Source](prettier/prettier@3.9.0...3.9.1) [diff](prettier/prettier@3.9.0...3.9.1) ##### CLI: Fix ignored file has been cached incorrectly ([#​19483](prettier/prettier#19483) by [@​kovsu](https://github.com/kovsu)) Bug details [#​18016](prettier/prettier#18016) ### [`v3.9.0`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#390) [Compare Source](prettier/prettier@3.8.5...3.9.0) [diff](prettier/prettier@3.8.5...3.9.0) 🔗 [Release Notes](https://prettier.io/blog/2026/06/27/3.9.0) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MS4zIiwidXBkYXRlZEluVmVyIjoiNDIuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://git.3caravelle.net/3Caravelle/renovate/pulls/42 Co-authored-by: Renovate Bot <renovate-bot@3caravelle.com> Co-committed-by: Renovate Bot <renovate-bot@3caravelle.com>
Description
Fix #19488
Still work in progress. I found root cause that this branch doesn't solve yet.
Checklist
(If changing the API or CLI) I’ve documented the changes I’ve made (in thedocs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.