Emmet for Atom: html结束标记后的自动注释.
我似乎在任何地方都找不到解决这个问题的办法,所以我只好在这里问了一下。
http://iaintnoextra.tumblr.com/post/68089741466/automatically-add-closing-comments-to-html-using
在崇高文本3中,使用上面链接中的emmet用户首选项文件,emmet在结束html标记后自动添加注释;例如:
div.container将产生:
<div class="container"></div><!-- /.container -->我似乎在Emmet的包设置中找不到任何地方可以在Atom V1上实现这一点。有人知道我可以在哪里修改它,这样它才能模仿相同的功能吗?
发布于 2015-09-10 09:01:05
http://www.devstavern.com/emmet/custom-comments-in-emmet-sublime-atom-and-others/
在上面的链接的帮助下,我自己解决了这个问题,下面是答案:
对同一行的评论:
{
"filter.commentAfter": "<!-- /<%= attr('id', '#') %><%= attr('class', '.') %> -->"
}关于新行的评论:
{
"filter.commentAfter": "\n<!-- /<%= attr('id', '#') %><%= attr('class', '.') %> -->"
}.atom\packages\emmet\node_modules\emmet\lib文件夹并编辑snippets.json。塔-达,起作用了!
更新(05/11/15):
确保在保存更改后重新启动Atom。
发布于 2016-12-27 14:53:59
我在C:\Users\AppData\Roaming\Brackets\extensions\user\brackets-emmet\node_modules\emmet\lib\filter上更改了html.js文件(标记生成器)
https://gist.github.com/mgundogdu38/a53af0bccd61bba4cefac56ab705d2b1
现在:

我找到html标记生成器库。html.js。2-我发现html标记生成器函数。它被称为processTag。3-我需要属性生成器函数。它被称为makeAttributesString。在我克隆之后。我叫"makeAttributesString2“:)
function makeAttributesString2(node, profile) {
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
return node.attributeList().map(function(a) {
var isBoolean = profile.isBoolean(a.name, a.value);
var attrName = profile.attributeName(a.name);
var attrValue = isBoolean ? attrName : a.value;
//i added there. if attribute is id. i added "." on head
if(attrName == "id")
{
return "#"+(attrValue || cursor);
}
//if attribute is class i added "." on head
if(attrName == "class")
{
return "."+(attrValue || cursor);
}
//else only tagname
if (isBoolean && profile.allowCompactBoolean()) {
return ' ' + attrName;
}
//end of my code
}).join('');
}发布于 2018-06-04 01:17:03
如果有人想在2018年用VS代码来做这件事,这就是我发现的效果。
"emmet.preferences": {
"filter.commentAfter": "<!-- /[#ID][.CLASS] -->"
},
"emmet.syntaxProfiles": {
"html": {
"filters": "html, c"
}
}
将其添加到现有的用户设置中,它应该只工作:)
https://stackoverflow.com/questions/32299333
复制相似问题