better-comments icon indicating copy to clipboard operation
better-comments copied to clipboard

Add Jade (Pug) Support

Open adamfaraj opened this issue 4 years ago • 5 comments

Trying to add Jade (Pug) support

adamfaraj avatar May 04 '20 20:05 adamfaraj

Oh very nice! I was just coming to figure out how to submit my fix for this. Looks like you have it pretty well covered, but I had to use all 3 params for it to work. I also added both languages pug/jade parcer.ts and as well in package.json.

        case "pug":
        case "jade":
            this.setCommentFormat("//", "<!--", "-->");
            break;

image

The reason I used "//" over "//-" is because I like how it handles exampled above. Also this keeps how it is handled more in line with Sass.

Sorry I am newish to github or I would have shared sooner (still need to learn how).

b1mind avatar May 06 '20 06:05 b1mind

Good catch, I will add .pug files to this PR.

I went with "//-" over "//" because I didn't want those comments appearing in the rendered HTML. Per the docs:

Pug also supports unbuffered comments. Simply add a hyphen (-) to the start of the comment. These are only for commenting on the Pug code itself, and do not appear in the rendered HTML.

Don't want users to see <!-- TODO: stuff that needs fixing --> if they ever were to inspect in dev tools.

adamfaraj avatar May 06 '20 13:05 adamfaraj

I went with "//-" over "//" because I didn't want those comments appearing in the rendered HTML. Per the docs:

This is totally understandable but it cause's conflicts for me. If you look at the above screenshot you will see that if "//" is used in better comments it works for both.

If you put "//-" only it will work for those types, and comments with "//" would be ignored still by the better colors extension.

// is the primary comment per docs as well. https://pugjs.org/language/comments.html

Sass works much the same way, so its up to the coder if you want your comments in markup.

b1mind avatar May 06 '20 17:05 b1mind

Good point. I'll edit the PR.

adamfaraj avatar May 06 '20 17:05 adamfaraj

Any update?

FlandreDaisuki avatar Jun 07 '22 03:06 FlandreDaisuki