edheltzel / better-nunjucks-for-visual-studio-code

🦾 Better Nunjucks for Visual Studio Code with Snippets
https://marketplace.visualstudio.com/items?itemName=ginfuru.better-nunjucks
MIT License
22 stars 1 forks source link

Default to HTML comment when outside of Nunjucks snippets in Markdown files #23

Open sghuang19 opened 2 months ago

sghuang19 commented 2 months ago

When the extension is installed, hitting Ctrl + / will use {%%} for comment everywhere in an .md file. Ideally this should only happen inside a Nunjucks snippet.

edheltzel commented 2 months ago

@sghuang19 could you explain your use case a little more? PR #18 changed the default behavior to what it is currently.

If you want HTML comments, you can always use Emmet to do this (which is the workaround) I set this with the keyboard shortcut option+ctrl+/ you could set it to ctrl+/ Screenshot 2024-08-15 at 8 53 08 AM

sghuang19 commented 2 months ago

Hi @edheltzel, thanks for getting back!

Markdown goes here.

<!-- comments here in texts should look like this -->
{# but actually they look like this #}

{% note primary no-icon %}
A callout here
{% endnote %}

Markdown goes here

So ideally when commenting outside of a tag, HTML comment should be used.

More about my use cases:

edheltzel commented 2 months ago

I use Eleventy a lot, which is the whole reason this extension even exists – I'm not versed in Hexo, but I'll dig into it to make sure they aren't doing something that is missing or could add value.

As for the NJK comments verse, the HTML comments - Nunjucks will not render the comment in the final output. If that is not what you want, then HTML comments are the way to go by using Emmet. One of the main issues here is how Nunjucks doesn't have a different syntax for multiline comments... initially, Better Nunjucks used snippets to create NJK comments, but adding the support from PR #18 makes more sense going forward.

I do have it on my roadmap to include some VSCode setting options to enable this behavior by default or not, but don't hold your breath 😅

* Emmet toggle comment _only works in `html` files_ for me. Doesn't work in Markdown ( why ?)

Try adding this to your VSCode settings (also inside of the readme, closer to the bottom):

"emmet.includeLanguages": {
"markdown": "html",
"nunjucks": "html",
},
"emmet.syntaxProfiles": {
"markdown": "html",
"nunjucks": "html",
},