Commit Graph

267 Commits

Author SHA1 Message Date
cloudhead
1d9b95f9e6 Evaluate function calls properly.
- `fun(f())` is now possible
- Anonymous can take normal strings
- Tests for `%()`
2010-04-30 14:07:05 -04:00
cloudhead
30773f942f New % function, to perform string interpolation 2010-04-30 14:06:36 -04:00
cloudhead
0aaf715232 fixed selector attributes not parsing with a '-' 2010-04-28 17:29:22 -04:00
cloudhead
4347211270 use a timer to check when the dom is ready, before showing errors 2010-04-26 14:22:37 -04:00
cloudhead
210e2e1886 automatically set less.env in certain conditions 2010-04-26 14:22:18 -04:00
cloudhead
535a0301ba Local Storage caching, and .less loading from disk
- .less files can now be loaded directly from disk
- nice error messages
- use HTML 5 storage to cache parsing
2010-04-25 19:42:49 -04:00
cloudhead
f6d1cf981e Overhaul of the error system
The parse() function no longer assumes the command-line is the output
device. We use less.writeError in node.js.
2010-04-25 19:39:21 -04:00
cloudhead
8c762b9e26 Support for pattern-matching on mixin calls. 2010-04-25 00:09:40 -04:00
cloudhead
7555c09707 More accurate parse error messages
Because of the backtracking, we lose the previous point of failure.
The solution is to store the furthest point the parser has parsed to,
when backtracking, and using it when showing parse errors.
2010-04-25 00:06:45 -04:00
cloudhead
1c52d6ac4d use a hash to store variables, fixes variable redifinition bug 2010-04-23 17:52:36 -04:00
cloudhead
1e6cbbf61d fixed bug with passing variables to functions 2010-04-23 13:49:55 -04:00
cloudhead
6778f51fc3 Added a couple colour functions
saturate, desaturate, lighten, darken, greyscale.
2010-04-23 13:36:50 -04:00
cloudhead
f0942511bb Fixed HSL
HSL colors weren't working properly. The values weren't being normalized
to {0, 1}.
2010-04-23 13:35:36 -04:00
cloudhead
7be2b22cfb the e() LESS function
used to escape strings in values.
Added Anonymous node to handle things like this.
2010-04-22 19:42:02 -04:00
cloudhead
1b5452652a refactored mixin.definition.eval 2010-04-22 13:47:01 -04:00
cloudhead
444401dc3c Fixed mixin calls not working from dynamic mixins
Dynamic mixins aren't treated enough like Rulesets.
There is some code duplication which needs to be cleaned up,
ideally they should share a prototype.
2010-04-22 13:34:49 -04:00
cloudhead
23640fe116 Fix dynamic mixins with nested rules
Dynamic mixins with more than one level of nesting wouldn't work.
This is now fixed. Also refactored mixin.definition.eval a little.
2010-04-22 13:07:41 -04:00
cloudhead
ac7916aa87 Reorganized some of the parsing rule order
- Fix for "{" not parsing
- Use some backtracking when necessary,
  it's prettier than crazy lookaheads.
2010-04-21 10:12:29 -04:00
cloudhead
03e669be21 less.js now works in firefox, safari and chrome 2010-04-01 22:37:59 -04:00
cloudhead
9a34a05555 @import with .css files no longer precompiles. This gives us some extra
flexibility.
2010-03-30 15:32:38 -04:00
cloudhead
1721e02ae7 We aren't using adapters anymore. 2010-03-29 22:56:07 -04:00
cloudhead
92bdf598c7 quote 'import' so it doesn't freak out 2010-03-29 22:24:33 -04:00
cloudhead
30bf1ff7f3 fix optimization option wrongly scoped 2010-03-29 22:13:36 -04:00
cloudhead
400427e47a merge 2010-03-27 02:27:59 -04:00
cloudhead
24bba952c7 removed lib/ext, moved lib/less.js to /index.js, moved Array/find to tree.find 2010-03-27 02:26:55 -04:00
cloudhead
3a474c9bae Created a compat.js file in build/, for browser compatiblity, moved trim() in
there. LESS builds to dist/ now.
2010-03-27 02:24:39 -04:00
cloudhead
41d701de1d Doc for Call, Comments, Operation.. 2010-03-23 18:33:17 -04:00
cloudhead
aad5ff6385 putting the operate function in operation.js, to facilitate access from browser code 2010-03-23 01:19:12 -04:00
cloudhead
a2133e4b78 functional browser based parsing + css node creation 2010-03-23 01:16:59 -04:00
cloudhead
3287a6ce2c fix typo in browser.js 2010-03-22 23:24:05 -04:00
cloudhead
be5d1999e3 no need for context passing 2010-03-22 23:15:25 -04:00
cloudhead
edf68ec0aa String/trim() 2010-03-22 23:13:47 -04:00
cloudhead
5977640040 optimization level is taken from env now 2010-03-22 23:13:24 -04:00
cloudhead
ca43e06db9 browser.js init -- very basic browser support - Makefile also builds for browser now 2010-03-22 23:12:58 -04:00
cloudhead
a349b9b3fb added render() convenience method. Returns an EventEmitter if no callback was passed. 2010-03-22 21:34:05 -04:00
cloudhead
259a4ad451 refactored the import mechanism, added some doc 2010-03-22 20:59:49 -04:00
cloudhead
336b655e16 allow for passing a context of evaluation to the importer 2010-03-22 20:59:11 -04:00
cloudhead
94f81a5fe0 removed unnecessary require 2010-03-22 20:15:06 -04:00
cloudhead
3253afad27 asynchronous import functionality! All tests passing. 2010-03-21 19:18:47 -04:00
cloudhead
ef97105ce3 made parser reentrant for import support 2010-03-21 19:17:37 -04:00
cloudhead
80905fdc58 no need to pass starting values to toCSS() anymore 2010-03-19 20:14:35 -04:00
cloudhead
40f8671bcd fix to undefined mixin error message 2010-03-19 19:46:37 -04:00
cloudhead
5ee3d47e11 operations.less now passes 2010-03-19 18:47:17 -04:00
cloudhead
10965a9034 allow for operations with no spaces, such as '4+5' 2010-03-19 18:46:42 -04:00
cloudhead
ef61aec5f1 refactored operand(), and take away parsing of -() 2010-03-19 18:05:36 -04:00
cloudhead
f973deec28 refactored rule() cause the closure slows things down too much for some reason 2010-03-19 17:56:43 -04:00
cloudhead
215ef05907 added import.js to less.js 2010-03-19 17:50:48 -04:00
cloudhead
53996b2364 parse() is now asynch, and uses a callback 2010-03-19 17:50:35 -04:00
cloudhead
5088fca537 import.js init 2010-03-18 18:44:03 -04:00
cloudhead
2c0dc223ce Parse @import properly. 2010-03-18 18:13:02 -04:00
cloudhead
00273d452c don't use process.mixin, it's deprecated 2010-03-18 16:42:25 -04:00
cloudhead
79a3b58fa8 fixed scope problem in parser 2010-03-18 14:49:10 -04:00
cloudhead
854f65f079 Refactored parsers.rule 2010-03-13 20:15:44 -05:00
cloudhead
61a7b2e9e7 Added lots more documentation to the parser 2010-03-13 20:14:44 -05:00
cloudhead
fe732e843c refactor of module system. Things work properly now, and it's all much cleaner. 2010-03-13 03:34:48 -05:00
cloudhead
e0623094fa part 2 of the comment pass 2010-03-12 15:03:05 -05:00
cloudhead
be11ab6b89 some eval functions for good measure 2010-03-11 15:36:50 -05:00
cloudhead
9c84b50d5b we need to make sure we're not eating a '-' in the operation parsing, it fucks up our generation of functions which start with a - 2010-03-11 15:36:32 -05:00
cloudhead
8adac6569e output directives properly 2010-03-11 15:35:23 -05:00
cloudhead
553aaecf6a font property parsing, mainly the 'small/12px' part. 2010-03-11 15:34:57 -05:00
cloudhead
9c0fb7174e Cache Selector/toCSS() 2010-03-09 23:58:05 -05:00
cloudhead
77b2a36059 Cache mixin lookups for a nice speed boost. 2010-03-09 23:56:49 -05:00
cloudhead
c4413facad did some refactoring in the parser, so we don't need to pass variables
to the $() function anymore. We also don't need to pass arrays around.
2010-03-08 23:45:57 -05:00
cloudhead
acd46cf7c6 refactoring of prototypes 2010-03-07 23:38:10 -05:00
cloudhead
07837a83a7 refactored variable lookup 2010-03-07 23:33:26 -05:00
cloudhead
6228f4a6d2 cache ruleset lookup 2010-03-07 23:11:20 -05:00
cloudhead
a68a2fc6bf cache variable lookup for a 20% speedup 2010-03-07 23:02:16 -05:00
cloudhead
be893c5993 support for nested rulesets inside dynamic mixins, with lexical scoping 2010-03-07 20:20:50 -05:00
cloudhead
d8838a01d0 eval() for Ruleset 2010-03-07 18:50:58 -05:00
cloudhead
7666c71b80 if something other than a Value was passed to the Rule constructor, wrap it in a Value 2010-03-07 18:50:31 -05:00
cloudhead
23775bda9b implemented dynamic mixins 2010-03-07 18:49:54 -05:00
cloudhead
57013ebdf9 comments.js init 2010-03-06 17:54:11 -05:00
cloudhead
2b0853de81 comments, wooh! 2010-03-06 17:53:55 -05:00
cloudhead
808bd55a95 let us just assume that a rule which contains subrules is a ruleset 2010-03-06 17:34:08 -05:00
cloudhead
7b151447b1 peek() can take a string too now 2010-03-05 21:51:45 -05:00
cloudhead
289a775e83 simplified rule regex 2010-03-05 21:45:23 -05:00
cloudhead
b2d242ba39 some optimizations to make the parser run faster 2010-03-05 21:08:41 -05:00
cloudhead
d08c1fe559 basic directive css output 2010-03-05 19:23:39 -05:00
cloudhead
f0f425de33 move node/ -> tree/ 2010-03-05 19:19:14 -05:00
cloudhead
287ecff0cf added version number to less.js 2010-03-05 15:33:50 -05:00
cloudhead
0af5632531 renamed string to quoted, to match the node 2010-03-05 14:56:27 -05:00
cloudhead
cd5bddff99 when parsing a string, capture the content too 2010-03-05 14:55:21 -05:00
cloudhead
00279d8a06 in an operation, inherit the unit of either operand 2010-03-05 13:36:24 -05:00
cloudhead
74ec956602 just return self if trying to evaluate compound values, seeing as we use eval() for variable lookup/eval 2010-03-05 13:32:07 -05:00
cloudhead
181712e662 minor refactoring in rulesets output 2010-03-05 11:42:52 -05:00
cloudhead
76d4e08b30 the first element of a selector effectively has a descendant combinator, if none was specified 2010-03-05 11:42:13 -05:00
cloudhead
476581f77a getting combinators to output properly. some little hacks, but it beats having a white-space sensitive grammar 2010-03-05 11:39:39 -05:00
cloudhead
b4f3e9029c output strings in attribute selectors properly 2010-03-04 16:13:48 -05:00
cloudhead
7e3d8bda32 if a function isnt found, just output it literally 2010-03-04 16:13:19 -05:00
cloudhead
7539ef7323 fixed closing bracket for alpha not showing 2010-03-04 13:55:00 -05:00
cloudhead
6b938971df fixed closing bracket for url not showing 2010-03-04 13:54:32 -05:00
cloudhead
2644014bdf refactored Ruleset/find() method, and added a match() method to Selector, to do selector matching. 2010-03-04 13:50:52 -05:00
cloudhead
3e8abb2abf typo 2010-03-04 13:48:37 -05:00
cloudhead
9cf5f74d31 Element constructor creates new Combinator if a string was passed 2010-03-04 13:48:24 -05:00
cloudhead
756e8d2434 skip variables in toCSS 2010-03-04 01:40:21 -05:00
cloudhead
4aea44f8f8 when evaluating a mixin, compile all matches, instead of just the first one 2010-03-03 22:13:14 -05:00
cloudhead
a1c8d50699 mixin definition constructor init 2010-03-03 21:22:11 -05:00
cloudhead
4767b264e7 basic mixins with namespaces working. swoosh. 2010-03-03 21:21:32 -05:00
cloudhead
fe0ed621b9 added ext/ folder, to hold some core prototype functions 2010-03-03 21:20:07 -05:00
cloudhead
095523bf59 Element constructor defaults to an empty Combinator, if none specified 2010-03-03 20:37:40 -05:00
cloudhead
e9c6645b2c end rule 2010-03-03 12:01:17 -05:00
cloudhead
e6c5c57755 inverse style to stylize 2010-03-03 12:01:06 -05:00
cloudhead
efab821115 parse mixins, including namespace. For now, lets focus on one mixin per rule 2010-03-03 12:00:55 -05:00
cloudhead
14bc6def86 a little clearer ParseError output 2010-03-03 11:59:30 -05:00
cloudhead
3e0ad2bf73 eval method for Keyword 2010-03-03 11:59:08 -05:00
cloudhead
76eb332b24 Use anonymous functions for the parsers.. It saves us some file size. 2010-03-02 14:58:06 -05:00
cloudhead
46060d466f evaluate arguments, before passing them to a function 2010-03-01 21:48:46 -05:00
cloudhead
2682b6dc16 support for hsl(), rgb() etc 2010-03-01 21:48:19 -05:00
cloudhead
60ac2374c9 get functions.js working 2010-03-01 20:03:43 -05:00
cloudhead
6ea12f7aa5 mixin.js init 2010-03-01 19:47:59 -05:00
cloudhead
0c6366faaf functions.js init 2010-03-01 19:47:48 -05:00
cloudhead
f70f6a542c merge node->tree changes 2010-03-01 19:47:32 -05:00
cloudhead
69d973ed29 tree.js init 2010-03-01 15:32:49 -05:00
cloudhead
5ee0209e8a don't use Usage: node [options] script.js [arguments]
-v, --version      print node's version
  --debug[=port]     enable remote debugging via given TCP port
  --debug-brk[=port] as above, but break in node.js and
                     wait for remote debugger to connect
  --cflags           print pre-processor and compiler flags
  --v8-options       print v8 command line options

Documentation can be found at http://nodejs.org/api.html or with 'man node', as it's, um, used by node. Use  instead. Also moved tree.node requires in tree.js
2010-03-01 15:32:21 -05:00
cloudhead
1032c84b98 refactored selector generation a little 2010-02-28 12:50:41 -05:00
cloudhead
f0c00ab2b4 create an empty Combinator if none was specified. Refactored Combinator generation, and added + ~ :: 2010-02-28 12:49:08 -05:00
cloudhead
35b452bf00 error = null, when starting a parse 2010-02-28 01:07:13 -05:00
cloudhead
8ac1bdf06c proper nested selector rendering, wooh. 2010-02-28 01:06:54 -05:00
cloudhead
cd764a2d8c give Element.toCSS a pre-space, useful when building new selectors 2010-02-28 01:05:27 -05:00
cloudhead
35af01d29a () around ternary operators 2010-02-28 01:03:22 -05:00
cloudhead
1c955c8cb3 fixed function name in alpha.js 2010-02-28 01:01:43 -05:00
cloudhead
1e16d0233c ParseErrors dont raise an exception anymore, we just set parser.error to the value of the error 2010-02-27 14:14:52 -05:00
cloudhead
c804ed2ef1 simplified code-gen loop 2010-02-27 14:13:28 -05:00
cloudhead
bd88ab89ef optimize dimension parsing, also fixes weird bug 2010-02-26 22:31:26 -05:00
cloudhead
b6b5d5f10a swap operands when dimension is first, in a color operation, use new operate() function 2010-02-26 22:31:04 -05:00
cloudhead
633660b7af refactored Color & Dimension operations 2010-02-26 22:30:30 -05:00
cloudhead
1c43df1b85 round numbers on color operations 2010-02-26 22:29:51 -05:00
cloudhead
a7ae7c8514 node.operate, to operate on values, based on a string op 2010-02-26 22:29:23 -05:00
cloudhead
fd8aa91ddc improved the chunkification process, and gave different options, as well as an option not to chunkify, through the optimization setting. The ideal split is now \n} 2010-02-26 16:34:49 -05:00
cloudhead
d97b30d9cc replace \r\n with \n 2010-02-26 14:50:26 -05:00
cloudhead
3ce2d7ad19 handle missing ; before a } 2010-02-26 14:49:07 -05:00
cloudhead
0c00a9c8ac handle empty property values 2010-02-26 14:48:32 -05:00
cloudhead
78ae5285d6 handle capitalized alpha() 2010-02-26 14:47:59 -05:00
cloudhead
4c1ce7075b eat tabs 2010-02-26 14:47:32 -05:00
cloudhead
e30851d384 fixed whitespace eating through chunks 2010-02-26 14:47:25 -05:00
cloudhead
c041deacdb fixed parsing of [disabled] style attribute selectors 2010-02-26 11:29:01 -05:00
cloudhead
7b96181f06 minor optimization in element parsing 2010-02-26 11:28:34 -05:00
cloudhead
2dea90afb7 parse *prop for ie 2010-02-26 10:54:48 -05:00
cloudhead
c8b11c7796 added ms unit 2010-02-26 10:36:26 -05:00
cloudhead
b60c296e6e throw a ParseError, instead of just an Error 2010-02-25 22:49:52 -05:00
cloudhead
543fb96a03 parse alpha in call() instead 2010-02-25 22:37:03 -05:00
cloudhead
3f893b8ddc alpha.js init 2010-02-25 22:32:34 -05:00
cloudhead
9970cb0124 parse IE's alpha() 2010-02-25 22:32:13 -05:00
cloudhead
8c45b58524 parse !important 2010-02-25 21:29:34 -05:00
cloudhead
3f753da627 ability to parse more complex directives 2010-02-25 21:29:21 -05:00
cloudhead
3d60c12a68 get attribute parsing going 2010-02-25 21:28:39 -05:00
cloudhead
cc1b5a91c3 pass a context to directive(), so it can parse a block 2010-02-25 21:28:14 -05:00
cloudhead
5038b215fc handle parse error at beginning of file 2010-02-25 21:27:45 -05:00
cloudhead
8a7747d15b url() parsing 2010-02-25 21:27:23 -05:00
cloudhead
b81160107e in a parens expression, just return the Expression for now 2010-02-25 18:01:03 -05:00