Python LESS compiler
Project description
Python LESS Compiler.
A compiler written in Python for the LESS language. For those of us not willing or able to have node.js installed in our environment. Not all features of LESS are supported (yet). Some features wil probably never be supported (JavaScript evaluation). This program uses PLY (Python Lex-Yacc) to tokenize / parse the input and is considerably slower than the NodeJS compiler. The plan is to utilize this to build in proper syntax checking and perhaps YUI compressing.
This is an early version, so you are likely to find bugs.
- For more information on LESS:
- Development files:
Supported features
Variables
String interpolation
Mixins (nested, calls, closures, recursive)
Guard expressions
Parametered mixins (class / id)
@arguments
Nesting
Escapes ~/e()
Expressions
Keyframe blocks
- Color functions (lighten, darken, saturate, desaturate, spin, hue, mix,
saturation, lightness)
Other functions (round, increment, decrement, format ‘%(’, …)
Differences from less.js
All colors are auto-formatted to #nnnnnn. eg, #f7e923
Does not preserve CSS comments
Not supported
JavaScript evaluation
Requirements
Python 2.6, 2.7, or 3.3
ply (Python Lex-Yacc) (check requirements.txt)
Installation
To install lesscpy from the Python Package Index, simply:
$ pip install lesscpy
To do a local system-wide install:
python setup.py install
Or simply place the package into your Python path. Or rather use packages provided by your distribution (openSUSE has them at least).
Compiler script Usage
usage: lesscpy [-h] [-v] [-I INCLUDE] [-V] [-x] [-X] [-t] [-s SPACES] [-o OUT]
[-r] [-f] [-m] [-D] [-g] [-S] [-L] [-N]
target
LessCss Compiler
positional arguments:
target less file or directory
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-I INCLUDE, --include INCLUDE
Included less-files (comma separated)
-V, --verbose Verbose mode
Formatting options:
-x, --minify Minify output
-X, --xminify Minify output, no end of block newlines
-t, --tabs Use tabs
-s SPACES, --spaces SPACES
Number of startline spaces (default 2)
Directory options:
Compiles all \*.less files in directory that have a newer timestamp than
it's css file.
-o OUT, --out OUT Output directory
-r, --recurse Recursive into subdirectorys
-f, --force Force recompile on all files
-m, --min-ending Add '.min' into output filename. eg, name.min.css
-D, --dry-run Dry run, do not write files
Debugging:
-g, --debug Debugging information
-S, --scopemap Scopemap
-L, --lex-only Run lexer on target
-N, --no-css No css output
Python usage
If you want to use the compiler from within Python, you can do it like this:
import lesscpy
from six import StringIO
print(lesscpy.compile(StringIO(u"a { border-width: 2px * 3; }"), minify=True))
The output will be:
a{border-width:6px;}
License
See the LICENSE file
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lesscpy-0.11.1.tar.gz
.
File metadata
- Download URL: lesscpy-0.11.1.tar.gz
- Upload date:
- Size: 159.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 640357af8599aec24462013c66043fa499de84c94c468b2b464e440a3ecf9b30 |
|
MD5 | d2ff23323591c7e8c77b2777bf9e53f0 |
|
BLAKE2b-256 | aea1b036086a377590b8f9ff006537f428eb23755cbb18ba4bcfcfb52b313b7b |
File details
Details for the file lesscpy-0.11.1-py2.py3-none-any.whl
.
File metadata
- Download URL: lesscpy-0.11.1-py2.py3-none-any.whl
- Upload date:
- Size: 160.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 965c5a26c865c556ed94c9261b1f9177b4969682822ecfe2c53aca59fa4bf826 |
|
MD5 | 8ed0c223a0751260e5c450d7552fdd07 |
|
BLAKE2b-256 | 7fe637429f7655c4b32754dbe8eaee3b25c7c6f5c596e83395f481a09675252d |