Python LESS编译器
项目描述
Python LESS编译器。
用Python编写的LESS语言的编译器。对于那些不愿意或无法在我们的环境中安装node.js的人来说。LESS的所有功能(目前)可能都不受支持。一些功能可能永远都不会被支持(JavaScript评估)。此程序使用PLY(Python Lex-Yacc)对输入进行标记/解析,比NodeJS编译器慢得多。计划利用此功能来实现正确的语法检查,也许还可以实现YUI压缩。
这是一个早期版本,所以你可能会发现一些错误。
- 有关LESS的更多信息
https://lesscss.org.cn/ 或 https://github.com/cloudhead/less.js
- 开发文件
支持的功能
变量
字符串插值
混入(嵌套、调用、闭包、递归)
守卫表达式
参数化混入(类/ID)
@arguments
嵌套
转义 ~/e()
表达式
关键帧块
- 颜色函数(亮化、暗化、饱和、去饱和、旋转、色调、混合、
饱和度、亮度)
其他函数(round、increment、decrement、格式‘%(’,…)
与less.js的区别
所有颜色都自动格式化为#nnnnnn。例如,#f7e923
不保留CSS注释
不支持
JavaScript评估
要求
Python 3.7 - 3.11,
ply (Python Lex-Yacc)(检查requirements.txt)
six
安装
要从Python包索引中安装lesscpy,请按以下操作
$ pip install lesscpy
进行本地系统级安装
python setup.py install
或者简单地将包放入您的Python路径中。或者使用您的发行版提供的包(至少openSUSE有它们)。
编译脚本使用方法
usage: 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 path
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
-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 files
Debugging:
-g, --debug Debugging information
-S, --scopemap Scopemap
-L, --lex-only Run lexer on target
-N, --no-css No css output
<< jtm@robot.is @_o >>
Python使用
如果您想在Python内部使用编译器,可以这样做
import lesscpy
from six import StringIO
print(lesscpy.compile(StringIO(u"a { border-width: 2px * 3; }"), minify=True))
输出将是
a{border-width:6px;}
许可证
查看LICENSE文件
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
lesscpy-0.15.1.tar.gz (177.2 kB 查看哈希值)
构建分发
lesscpy-0.15.1-py2.py3-none-any.whl (46.7 kB 查看哈希值)