ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

e​CSStractor

by hudochenkov ST2/ST3

Sublime Text plugin for extracting class names from HTML and generate CSS stylesheet for following work.

Details

Installs

  • Total 109
  • Win 60
  • OS X 43
  • Linux 6
Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9 Feb 8 Feb 7 Feb 6 Feb 5 Feb 4 Feb 3 Feb 2 Feb 1 Jan 31 Jan 30 Jan 29 Jan 28 Jan 27 Jan 26 Jan 25 Jan 24 Jan 23 Jan 22 Jan 21 Jan 20 Jan 19
Windows 0 1 1 0 0 2 1 3 1 1 1 1 0 4 5 3 0 1 1 0 2 1 3 0 1 4 1 0 0 3 1 1 2 3 6 10 3 4 3 1 0 0 0 0 0
OS X 0 5 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 3 1 0 0 6 1 2 5 8 3 5 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

eCSStractor

Sublime Text plugin for extracting class names from HTML and generate CSS stylesheet for following work.

Default extracting:

ecss_normal

With BEM nesting:

ecss_bem

Usage

Open any document contain HTML and do one of the following:

  • Press Cmd+Shift+X on Mac OS X or Ctrl+Shift+X on Windows/Linux.
  • Go to Tools → eCSStractor → Run
  • Right click and select eCSStractor → Run

Then you will see new tab with CSS selectors extracted from document.

Plugin can process either selected text or whole file.

You can explicit Run (with BEM Nesting) or Run (without BEM Nesting) regardless bem_nesting option from Command Palette, Menu or Context Menu.

Options

The default settings can be viewed by accessing the Preferences → Package Settings → eCSStractor → Settings – Default menu entry. To ensure settings are not lost when the package is upgraded, make sure all edits are saved to Settings – User.

brackets

Add brackets. Useful for Sass syntax and Stylus.

Default: true

ignore

List of classnames to ignore. Useful for helper classes, that probably already described. Ex., clearfix. See Settings – Default for example.

Default: empty

ignore_regex

Similar to ignore option, but use RegEx to ignore. Ex., ^js- will ingore all classes started with js-. See Settings – Default for example.

Default: empty

destination

Where to put result: new tab (tab) or copy to clipboard (clipboard)

Default: tab

bem_nesting

BEM Nesting. Generate nested stylesheet for preprocessors rather simple stylesheet. You can see difference in Example section of this readme.

Default: false

Options only for BEM Nesting is on

indentation

Indentation.

Default: \t

bem.element_separator

Separator between block and element names.

Default: __

bem.modifier_separator

Separator between block or element and they modifier.

Default:

preprocessor.parent_symbol

Parent symbol. Ex.: &__element {}

Default: &

Example

Source:

<ul class="nav nav--main">
    <li class="nav__item"><a href="" class="nav__link">Home</a></li>
    <li class="nav__item"><a href="" class="nav__link">Shop</a></li>
    <li class="nav__item"><a href="" class="nav__link nav__link--special">About</a></li>
</ul>

Run eCSStractor (BEM Nesting is off):

.nav {
}
.nav--main {
}
.nav__item {
}
.nav__link {
}
.nav__link--special {
}

Run eCSStractor (BEM Nesting is on):

.nav {
    &--main {
    }
    &__item {
    }
    &__link {
        &--special {
        }
    }
}

Installation

Most simple way it's install with Package Control.

Open the Command Palette Cmd+Shift+P (OS X) or Ctrl+Shift+P (Linux/Windows) and select “Package Control: Install Package”, then search for eCSStractor.

Similar tool

I've been inspired by extractCSS online tool. This tool have much more functions, but not very convenient for regular use.