Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lesscpy/lesscpy
Python LESS compiler
https://github.com/lesscpy/lesscpy
compiler css less lex ply python yacc
Last synced: about 14 hours ago
JSON representation
Python LESS compiler
- Host: GitHub
- URL: https://github.com/lesscpy/lesscpy
- Owner: lesscpy
- License: mit
- Created: 2012-01-28T14:45:59.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2023-09-23T15:39:53.000Z (over 1 year ago)
- Last Synced: 2025-01-24T23:12:05.327Z (8 days ago)
- Topics: compiler, css, less, lex, ply, python, yacc
- Language: Less
- Homepage:
- Size: 798 KB
- Stars: 144
- Watchers: 9
- Forks: 47
- Open Issues: 37
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
LESSCPY
=======.. image:: https://travis-ci.org/lesscpy/lesscpy.png?branch=master
:target: https://travis-ci.org/lesscpy/lesscpy.. image:: https://coveralls.io/repos/lesscpy/lesscpy/badge.png
:target: https://coveralls.io/r/lesscpy/lesscpy.. image:: https://img.shields.io/pypi/dm/lesscpy.svg
:target: https://pypi.python.org/pypi/lesscpy.. image:: https://img.shields.io/pypi/v/lesscpy.svg
:target: https://pypi.python.org/pypi/lesscpy.. image:: https://img.shields.io/pypi/wheel/lesscpy.svg
:target: https://pypi.python.org/pypi/lesscpy
:alt: Wheel Status.. image:: https://img.shields.io/pypi/l/lesscpy.svg
:target: https://pypi.python.org/pypi/lesscpy
:alt: LicensePython 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:
http://lesscss.org/ or https://github.com/cloudhead/less.js
Development files:
https://github.com/lesscpy/lesscpySupported 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 commentsNot supported
-------------- JavaScript evaluation
Requirements
------------- Python 3.7 - 3.11,
- ply (Python Lex-Yacc) (check requirements.txt)Installation
------------To install lesscpy from the `Python Package Index`_, simply:
.. code-block:: bash
$ pip install lesscpy
To do a local system-wide install:
.. code-block:: bash
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
---------------------
.. code-block:: textusage: lesscpy [-h] [-v] [-I INCLUDE] [-V] [-C] [-x] [-X] [-t] [-s SPACES]
[-o OUT] [-r] [-f] [-m] [-D] [-g] [-S] [-L] [-N]
target [output]LessCss Compiler
positional arguments:
target less file or directory
output output file pathoptional 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
-C, --dont_create_dirs
Creates directories when outputing files (lessc non-
compatible)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 filesDebugging:
-g, --debug Debugging information
-S, --scopemap Scopemap
-L, --lex-only Run lexer on target
-N, --no-css No css output<< [email protected] @_o >>
Python usage
------------If you want to use the compiler from within Python, you can do it like this:
.. code-block:: python
import lesscpy
print(lesscpy.compile(StringIO(u"a { border-width: 2px * 3; }"), minify=True))
The output will be:
.. code-block:: text
a{border-width:6px;}
License
-------See the LICENSE file
.. _`Python Package Index`: https://pypi.python.org/pypi/lesscpy