无python编译器
lesscp的Python项目详细描述
无python编译器。
用python为less语言编写的编译器。为了那些我们不愿意 或者能够在我们的环境中安装node.js。不是所有的功能 得到支持。一些特性可能永远不受支持(javascript 评估)。这个程序使用ply(python lex yacc)来标记/解析 输入,比nodejs编译器慢得多。计划是 利用这个来构建正确的语法检查,也许还有yui压缩。
这是一个早期版本,所以您可能会发现错误。
- 有关less的更多信息:
- http://lesscss.org/或https://github.com/cloudhead/less.js
- 开发文件:
- https://github.com/lesscpy/lesscpy
支持的功能
- 变量
- 字符串插值
- Mixins(嵌套、调用、闭包、递归)
- 保护表达式 Parametered mixins(班/ID)
- @参数
- 嵌套
- 转义~/e()
- 表达式
- 关键帧块
- 颜色功能(变亮、变暗、饱和、去饱和、旋转、色调、混合,
- 饱和度、亮度)
- 其他函数(round、increment、decrement、format“%(”,…)
与less.js的区别
- 所有颜色都自动格式化为nnnnn。例如,f7e923
- 不保留css注释
不支持
- javascript评估
要求
- python 2.6、2.7、3.3、3.4或3.5
- ply(python lex yacc)(check requirements.txt)
安装
要从Python Package Index安装lesscpy,只需:
$ pip install lesscpy
要进行本地系统范围的安装:
python setup.py install
或者简单地将包放到python路径中。或者使用软件包 由您的发行版提供(opensuse至少有)。
编译器脚本用法
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用法
如果您想在python中使用编译器,可以这样做:
importlesscpyfromsiximportStringIOprint(lesscpy.compile(StringIO(u"a { border-width: 2px * 3; }"),minify=True))
输出为:
a{border-width:6px;}
许可证
请参见许可文件