Snippet. Selection insert changes markdown to HTML entities #236

Closed
opened 2026-10-05 02:35:23 +02:00 by adam · 2 comments
Owner

Describe the bug

  • In Hugo I use a shortcode that adds a DIV container arround a selected markdown block in content and "markdownifies" this block.
{{- $css_class := .Get 0 | default "info" -}}

<div class="bd-callout bd-callout-{{ $css_class }}">
{{ .Inner | markdownify }}
</div>
  • Example in content file (see markdown for <CODE>)
{{< ghsvs/callout info >}}
Please use `<h3>` not `<h2>`!
{{< /ghsvs/callout >}}
  • I created a snippet
"Callout": {
	"description": "",
	"body": [
		"{{< ghsvs/callout info >}}",
		"[[selection]]",
		"{{< /ghsvs/callout >}}"
	],
	"fields": [
		{
			"name": "selection",
			"title": "selection",
			"type": "string",
			"single": false,
			"default": "FM_SELECTED_TEXT"
		}
	]
}
  • When I use it the content is changed (see HTML entities) by Front-Matter and changes the selected text like this:
{{< ghsvs/callout info >}}
Please use &#x60;&lt;h3&gt;&#x60; not &#x60;&lt;h2&gt;&#x60;!
{{< /ghsvs/callout >}}

which results in wrong output in HTML.

Expected behavior
No change of selected markdown text.

Desktop (please complete the following information):

  • OS: [WIN10, WSL1, Debian]
  • VSCode
  • Front-Matter 7.
**Describe the bug** - In Hugo I use a shortcode that adds a `DIV `container arround a selected markdown block in content and "markdownifies" this block. ``` {{- $css_class := .Get 0 | default "info" -}} <div class="bd-callout bd-callout-{{ $css_class }}"> {{ .Inner | markdownify }} </div> ``` - Example in content file (see markdown for `<CODE>`) ``` {{< ghsvs/callout info >}} Please use `<h3>` not `<h2>`! {{< /ghsvs/callout >}} ``` - I created a snippet ``` "Callout": { "description": "", "body": [ "{{< ghsvs/callout info >}}", "[[selection]]", "{{< /ghsvs/callout >}}" ], "fields": [ { "name": "selection", "title": "selection", "type": "string", "single": false, "default": "FM_SELECTED_TEXT" } ] } ``` - When I use it the content is changed (see HTML entities) by Front-Matter and changes the selected text like this: ``` {{< ghsvs/callout info >}} Please use &#x60;&lt;h3&gt;&#x60; not &#x60;&lt;h2&gt;&#x60;! {{< /ghsvs/callout >}} ``` which results in wrong output in HTML. **Expected behavior** No change of selected markdown text. **Desktop (please complete the following information):** - OS: [WIN10, WSL1, Debian] - VSCode - Front-Matter 7. <!-- github-sync-id:1178096897 -->
adam closed this issue 2026-10-05 02:35:23 +02:00
Author
Owner

Hi @ReLater, that is the default behavior.

All variables are HTML-escaped by default, if you want to add unescaped HTML content, you need to add an & before your variable name. Example: [[&selection]].

Hi @ReLater, that is the default behavior. All variables are HTML-escaped by default, if you want to add unescaped HTML content, you need to add an `&` before your variable name. Example: `[[&selection]]`. <!-- github-comment-id:1076381587 -->
Author
Owner

Ok. Thanks a lot. Read in docs but then forgotten ;-) Now I will remember forever...

Ok. Thanks a lot. Read in docs but then forgotten ;-) Now I will remember forever... <!-- github-comment-id:1076532062 -->
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#236