跨 CSS 文件重命名 HTML 类

发布于 2024-08-28 13:57:40 字数 204 浏览 4 评论 0原文

如果我有 100 个 HTML 文件,这些文件使用一组在 CSS 文件中用作选择器的类,是否有一个实用程序可以用来智能地重命名这些类?

我知道每个编辑器/IDE 都有在项目中查找/替换的功能。使用 sed 你可以做同样的事情。这并不智能,因为它只是简单的字符串替换。我想知道有一个工具能够真正理解 CSS 类是什么以及如何替换它的实例。我想一个奇特的正则表达式可以做同样的事情。

If I have 100 HTML files that use a set of classes that are used as selectors in CSS files, is there a utility that I can use to intelligently rename the classes?

I know that every editor/IDE has a find/replace in project feature. Using sed you can do the same thing. This is not intelligent because it is a simple string replace. I want to know of a tool that actually understands what a CSS class is and how to replace instances of it. I suppose a fancy regular expression can do the same thing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝眼睛不忧郁 2024-09-04 13:57:40

我认为您正在寻找 Google 的闭包样式表
其中之一闭包样式表功能是重命名

闭包样式表重命名功能的示例如下。

<style>
  .descriptive-parent-class-name .descriptive-element-class-name {color:red;}
</style>
<div class="descriptive-parent-class-name">
  <p class="descriptive-element-class-name">Lorem ipsum</p>
  <p class="descriptive-element-class-name">Lorem ipsum</p>
</div>

也会

<style>
  .a-b .a-c {color:red;}
</style>
<div class="a-b">
  <p class="a-c">Lorem ipsum</p>
  <p class="a-c">Lorem ipsum</p>
</div>

有进一步的缩小功能。

另请检查闭包编译器

如果你检查任何 Google/Facebook 页面,你会发现它们的类和 ID 名称几乎不会超过 4 个随机字符

I think you are looking for Google's Closure stylesheets.
One of the closure stylesheets features is renaming.

example of closure stylesheets renaming features as following.

<style>
  .descriptive-parent-class-name .descriptive-element-class-name {color:red;}
</style>
<div class="descriptive-parent-class-name">
  <p class="descriptive-element-class-name">Lorem ipsum</p>
  <p class="descriptive-element-class-name">Lorem ipsum</p>
</div>

would become

<style>
  .a-b .a-c {color:red;}
</style>
<div class="a-b">
  <p class="a-c">Lorem ipsum</p>
  <p class="a-c">Lorem ipsum</p>
</div>

There'll be further minification features too.

Also check closure Compiler.

if you inspect any Google/Facebook page, you'll see their class and ID names are almost never longer than 4 random characters

寂寞清仓 2024-09-04 13:57:40

看一下 Netbeans 6.9 m1。它具有 CSS 重构/查找用法支持,也许这就是您正在寻找的。

http://wiki.netbeans.org/NewAndNoteworthy69m1#CSS_Refactoring_.2F_Find_Usages_Support

Take a look at Netbeans 6.9 m1. It has CSS Refactoring / Find Usages Support maybe that is what are you looking for.

http://wiki.netbeans.org/NewAndNoteworthy69m1#CSS_Refactoring_.2F_Find_Usages_Support

以可爱出名 2024-09-04 13:57:40

如果这仍然是最新的,那么有一个名为 rcs 的库,它是 rename-css-selectors 的缩写。

这是库,它非常容易使用: rcs-core

它附带很多插件,例如 webpack、parcel 和 node: https://github.com /JPeer264/node-rcs-core#plugins

If this is still up-to-date there is a library called rcs short for rename-css-selectors.

This is the library and it is pretty easy to use: rcs-core

It comes with a lot of plugins, such as webpack, parcel and node: https://github.com/JPeer264/node-rcs-core#plugins

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文