Lessc
class Lessc (View source)
The LESS compiler and parser.
Converting LESS to CSS is a three stage process. The incoming file is parsed
by lessc_parser into a syntax tree, then it is compiled into another tree
representing the CSS structure by lessc. The CSS tree is fed into a
formatter, like lessc_formatter which then outputs CSS as a string.
During the first compile, all values are reduced, which means that their types are brought to the lowest form before being dump as strings. This handles math equations, variable dereferences, and the like.
The parse function of lessc is the entry point.
In summary:
The lessc class creates an instance of the parser, feeds it LESS code,
then transforms the resulting tree to a CSS tree. This class also holds the
evaluation context, such as all available mixins and variables at any given
time.
The lessc_parser class is only concerned with parsing its input.
The lessc_formatter takes a CSS tree, and dumps it to a formatted string,
handling things like indentation.
Properties
| static | $VERSION | ||
| static | $TRUE | ||
| static | $FALSE | ||
| protected | $libFunctions | ||
| protected | $registeredVars | ||
| protected | $preserveComments | ||
| $vPrefix | |||
| $mPrefix | |||
| $parentSelector | |||
| $importDisabled | |||
| $importDir | |||
| $scope | |||
| $formatter | |||
| $formatterName | |||
| $parser | |||
| $_parseFile | |||
| $env | |||
| $count | |||
| protected | $numberPrecision | ||
| protected | $allParsedFiles | ||
| protected | $sourceParser | ||
| protected | $sourceLoc | ||
| static protected | $nextImportId | ||
| static protected | $cssColors |
Methods
No description
fileExists
No description
No description
No description
No description
Recursively compiles a block.
No description
No description
No description
No description
No description
No description
Deduplicate lines in a block. Comments are not deduplicated. If a duplicate rule is detected, the comments immediately preceding each occurence are consolidated.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Compiles a primitive value into a CSS property value.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Given an url, decide whether to output a regular link or the base64-encoded contents of the file
No description
No description
No description
No description
No description
No description
Helper function to get arguments for color manipulation functions.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Mix color with white in variable proportion.
Mix color with black in variable proportion.
lib_mix mixes two colors by weight mix(@color1, @color2, [@weight: 50%]); http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
lib_contrast
No description
No description
No description
No description
No description
No description
Converts a hsl array into a color value in rgb.
No description
Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Initialize any static state, can initialize parser for a file $opts isn't used yet
No description
No description
No description
Execute lessphp on a .less file or a lessphp cache structure
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Uses the current value of $this->count to show line and line number
No description
No description
Details
protected
findImport($url)
No description
protected bool
fileExists(string $name)
fileExists
static
compressList($items, $delim)
No description
static
preg_quote($what)
No description
protected
tryImport($importPath, $parentBlock, $out)
No description
protected
compileImportedProps($props, $block, $out, $sourceParser, $importDir)
No description
protected
compileBlock($block)
Recursively compiles a block.
A block is analogous to a CSS block in most cases. A single LESS document is encapsulated in a block when parsed, but it does not have parent tags so all of it's children appear on the root level when compiled.
Blocks are made up of props and children.
Props are property instructions, array tuples which describe an action to be taken, eg. write a property, set a variable, mixin a block.
The children of a block are just all the blocks that are defined within. This is used to look up mixins when performing a mixin.
Compiling the block involves pushing a fresh environment on the stack, and iterating through the props, compiling each one.
See Lessc::compileProp()
protected
compileCSSBlock($block)
No description
protected
compileMedia($media)
No description
protected
mediaParent($scope)
No description
protected
compileNestedBlock($block, $selectors)
No description
protected
compileRoot($root)
No description
protected
compileProps($block, $out)
No description
protected
deduplicate($lines)
Deduplicate lines in a block. Comments are not deduplicated. If a duplicate rule is detected, the comments immediately preceding each occurence are consolidated.
protected
sortProps($props, $split = false)
No description
protected
compileMediaQuery($queries)
No description
protected
multiplyMedia($env, $childQueries = null)
No description
protected
expandParentSelectors($tag, $replace)
No description
protected
findClosestSelectors()
No description
protected
multiplySelectors($selectors)
No description
protected
compileSelectors($selectors)
No description
protected
eq($left, $right)
No description
protected
patternMatch($block, $orderedArgs, $keywordArgs)
No description
protected
patternMatchAll($blocks, $orderedArgs, $keywordArgs, $skip = array())
No description
protected
findBlocks($searchIn, $path, $orderedArgs, $keywordArgs, $seen = array())
No description
protected
zipSetArgs($args, $orderedValues, $keywordValues)
No description
protected
compileProp($prop, $block, $out)
No description
compileValue($value)
Compiles a primitive value into a CSS property value.
Values in lessphp are typed by being wrapped in arrays, their format is typically:
array(type, contents [, additional_contents]*)
The input is expected to be reduced. This function will not work on things like expressions and variables.
protected
lib_pow($args)
No description
protected
lib_pi()
No description
protected
lib_mod($args)
No description
protected
lib_tan($num)
No description
protected
lib_sin($num)
No description
protected
lib_cos($num)
No description
protected
lib_atan($num)
No description
protected
lib_asin($num)
No description
protected
lib_acos($num)
No description
protected
lib_sqrt($num)
No description
protected
lib_extract($value)
No description
protected
lib_isnumber($value)
No description
protected
lib_isstring($value)
No description
protected
lib_iscolor($value)
No description
protected
lib_iskeyword($value)
No description
protected
lib_ispixel($value)
No description
protected
lib_ispercentage($value)
No description
protected
lib_isem($value)
No description
protected
lib_isrem($value)
No description
protected
lib_rgbahex($color)
No description
protected
lib_argb($color)
No description
protected string
lib_data_uri(array $value)
Given an url, decide whether to output a regular link or the base64-encoded contents of the file
protected
lib_e($arg)
No description
protected
lib__sprintf($args)
No description
protected
lib_floor($arg)
No description
protected
lib_ceil($arg)
No description
protected
lib_round($arg)
No description
protected
lib_unit($arg)
No description
colorArgs($args)
Helper function to get arguments for color manipulation functions.
takes a list that contains a color like thing and a percentage
protected
lib_darken($args)
No description
protected
lib_lighten($args)
No description
protected
lib_saturate($args)
No description
protected
lib_desaturate($args)
No description
protected
lib_spin($args)
No description
protected
lib_fadeout($args)
No description
protected
lib_fadein($args)
No description
protected
lib_hue($color)
No description
protected
lib_saturation($color)
No description
protected
lib_lightness($color)
No description
protected
lib_alpha($value)
No description
protected
lib_fade($args)
No description
protected
lib_percentage($arg)
No description
protected array
lib_tint($args)
Mix color with white in variable proportion.
It is the same as calling mix(#ffffff, @color, @weight).
tint(@color, [@weight: 50%]);
protected array
lib_shade($args)
Mix color with black in variable proportion.
It is the same as calling mix(#000000, @color, @weight)
shade(@color, [@weight: 50%]);
protected array
lib_mix(array $args)
lib_mix mixes two colors by weight mix(@color1, @color2, [@weight: 50%]); http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
protected array
lib_contrast(array $args)
lib_contrast
protected
lib_luma($color)
No description
assertColor($value, $error = "expected color value")
No description
assertNumber($value, $error = "expecting number")
No description
assertArgs($value, $expectedArgs, $name = "")
No description
protected
toHSL($color)
No description
protected
toRGB_helper($comp, $temp1, $temp2)
No description
protected
toRGB($color)
Converts a hsl array into a color value in rgb.
Expects H to be in range of 0 to 360, S and L in 0 to 100
protected
clamp($v, $max = 1, $min = 0)
No description
protected
funcToColor($func)
Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.
protected
reduce($value, $forExpression = false)
No description
protected
coerceColor($value)
No description
protected
coerceString($value)
No description
protected
flattenList($value)
No description
toBool($a)
No description
protected
evaluate($exp)
No description
protected
stringConcatenate($left, $right)
No description
protected
fixColor($c)
No description
protected
op_number_color($op, $lft, $rgt)
No description
protected
op_color_number($op, $lft, $rgt)
No description
protected
op_color_color($op, $left, $right)
No description
lib_red($color)
No description
lib_green($color)
No description
lib_blue($color)
No description
protected
op_number_number($op, $left, $right)
No description
protected
makeOutputBlock($type, $selectors = null)
No description
protected
pushEnv($block = null)
No description
protected
popEnv()
No description
protected
set($name, $value)
No description
protected
get($name)
No description
protected
injectVariables($args)
No description
__construct($fname = null)
Initialize any static state, can initialize parser for a file $opts isn't used yet
compile($string, $name = null)
No description
compileFile($fname, $outFname = null)
No description
checkedCompile($in, $out)
No description
array|null
cachedCompile(mixed $in, bool $force = false)
Execute lessphp on a .less file or a lessphp cache structure
The lessphp cache structure contains information about a specific less file having been parsed. It can be used as a hint for future calls to determine whether or not a rebuild is required.
The cache structure contains two important keys that may be used externally:
compiled: The final compiled CSS updated: The time (in seconds) the CSS was last compiled
The cache structure is a plain-ol' PHP associative array and can be serialized and unserialized without a hitch.
parse($str = null, $initialVariables = null)
No description
protected
makeParser($name)
No description
setFormatter($name)
No description
protected
newFormatter()
No description
setPreserveComments($preserve)
No description
registerFunction($name, $func)
No description
unregisterFunction($name)
No description
setVariables($variables)
No description
unsetVariable($name)
No description
setImportDir($dirs)
No description
addImportDir($dir)
No description
allParsedFiles()
No description
addParsedFile($file)
No description
throwError($msg = null)
Uses the current value of $this->count to show line and line number
static
ccompile($in, $out, $less = null)
No description
static
cexecute($in, $force = false, $less = null)
No description