Skip to content

Commit

Permalink
fix: fix comments detection in Astro front matter (fix #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Aug 24, 2024
1 parent 941308b commit a6c2a03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion markup_fmt/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ impl<'s> Parser<'s> {
Some((_, '}')) if matches!(pair_stack.last(), Some('$' | '{')) => {
pair_stack.pop();
}
Some((_, '/')) => {
Some((_, '/')) if !matches!(pair_stack.last(), Some('\'' | '"' | '`')) => {
if let Some((_, c)) = self.chars.next_if(|(_, c)| *c == '/' || *c == '*') {
pair_stack.push(c);
}
Expand Down
8 changes: 8 additions & 0 deletions markup_fmt/tests/fmt/astro/issue-9/7.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"//"
'//'
`//`
`//${
//
}`
---
11 changes: 11 additions & 0 deletions markup_fmt/tests/fmt/astro/issue-9/7.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: markup_fmt/tests/fmt.rs
---
---
"//"
'//'
`//`
`//${
//
}`
---

0 comments on commit a6c2a03

Please sign in to comment.