Issue: Square brackets within a snippet are incorrectly replaced #722

Closed
opened 2026-10-05 03:02:10 +02:00 by adam · 3 comments
Owner

Describe the bug
I am creating a new media snippet that inserts markdown. The markdown output requires square brackets ([) but the variable substitution breaks the output.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new media snippet
  2. Insert the following code:
{
  "$schema": "https://frontmatter.codes/config/content.snippets.schema.json",
  "title": "Image with caption (Markdown)",
  "description": "Insert a responsive image with a caption (Markdown)",
  "body": "![[[alt]]]([[&mediaUrl]] \"[[caption]]\")",
  "isMediaSnippet": true,
  "fields": []
}
  1. Open a markdown file and attempt to insert the snippet
  2. The output fails due to the incorrect substitution on the triple bracket [[[

This is an example of the output:

!](/assets/img/en.jpg "Caption")

Expected behavior
I expect the following output:

![Alt](/assets/img/en.jpg "Caption")

Is there a way to escape the brackets I want to keep?

Device:

  • OS: Fedora 41
  • Front Matter CMS Version: 10.7.0
  • Browser: all
**Describe the bug** I am creating a new media snippet that inserts markdown. The markdown output requires square brackets (`[`) but the variable substitution breaks the output. **To Reproduce** Steps to reproduce the behavior: 1. Create a new media snippet 2. Insert the following code: ``` json { "$schema": "https://frontmatter.codes/config/content.snippets.schema.json", "title": "Image with caption (Markdown)", "description": "Insert a responsive image with a caption (Markdown)", "body": "![[[alt]]]([[&mediaUrl]] \"[[caption]]\")", "isMediaSnippet": true, "fields": [] } ``` 3. Open a markdown file and attempt to insert the snippet 4. The output fails due to the incorrect substitution on the triple bracket `[[[` This is an example of the output: ``` !](/assets/img/en.jpg "Caption") ``` **Expected behavior** I expect the following output: ``` ![Alt](/assets/img/en.jpg "Caption") ``` Is there a way to escape the brackets I want to keep? **Device:** - OS: Fedora 41 - Front Matter CMS Version: 10.7.0 - Browser: all <!-- github-sync-id:2904740057 -->
adam closed this issue 2026-10-05 03:02:10 +02:00
Author
Owner

I assume you tested \[[[something]]\] to make the outer brackets literal, and it didn't work? From my understanding (low level, not the expert here) I think the outer brackets need to be somehow encoded so Front Matter is not trying to replace those.

I assume you tested `\[[[something]]\]` to make the outer brackets literal, and it didn't work? From my understanding (low level, not the expert here) I think the outer brackets need to be somehow encoded so Front Matter is not trying to replace those. <!-- github-comment-id:2708329441 -->
Author
Owner

Hi @scottsweb, internally, we use [[ and ]] for replacing the placeholders. You have the option to change this with the openingTags and closingTags properties.

"<snippet title>": {
  "description": "Description",
  "body": [],
  "fields": [],
  "openingTags": "[[",
  "closingTags": "]]"
}

If you change it to use curly brackets and update the body of the snippet to: "![{{alt}}]({{&mediaUrl}} \"{{caption}}\")" - it should work.

Hi @scottsweb, internally, we use `[[` and `]]` for replacing the placeholders. You have the option to change this with the `openingTags` and `closingTags` properties. ```json "<snippet title>": { "description": "Description", "body": [], "fields": [], "openingTags": "[[", "closingTags": "]]" } ``` If you change it to use curly brackets and update the body of the snippet to: `"![{{alt}}]({{&mediaUrl}} \"{{caption}}\")"` - it should work. <!-- github-comment-id:2708345613 -->
Author
Owner

That worked perfectly @estruyf - thanks very much for the suggestions both of you. Closing.

That worked perfectly @estruyf - thanks very much for the suggestions both of you. Closing. <!-- github-comment-id:2708364275 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#722