Socket
Socket
Sign inDemoInstall

stylus

Package Overview
Dependencies
Maintainers
3
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylus - npm Package Compare versions

Comparing version 0.53.0 to 0.54.0

lib/functions/slice.js

32

History.md

@@ -0,1 +1,27 @@

0.54.0 / 2016-03-05
* Feature: Added initial reference selector.
* Feature: New `embedurl()` bif with optional utf8 uncoding support for SVG.
* Feature: New `index()` bif.
* Feature: New `percentage()` bif.
* Feature: New `slice()` bif, #2115.
* Feature: Support for UTF-8 encoding of urls, #2084.
* Feature: Added `global` flag to `define()` function.
* Feature: `match()` bif now returns the matched values instead of a boolean, #2109.
* Feature: Added an optional `flags` argument to `match()` bif, #2109.
* Docs: Added basic “getting started” to Readme, #2073.
* Docs: Updated information about error reporting.
* Fix: `selectors()` now returns proper subselectors.
* Fix: No more unneeded spaces with partial reference selector using ranges.
* Fix: Proper evaluating of the default arguments.
* Fix: Evaluate variables in current-media function.
* Fix: Validate regexp flags for `match` function.
* Fix: Proper conditional assignment and "define" method.
* Fix: Proper relative paths in sourcemaps if --out flag is set to a filename.
* Fix: Proper errors with `--include-css` and `--resolve-url` used concurrently.
* Fix: [Evaluator] Support for function as a default argument for functions.
* Fix: [Lexer] Proper multiline comments inside multiline expressions.
* Fix: [JS API] Proper variables from options object inside expressions.
* Fix: [Renderer] No more caching of parsed AST for deps-resolver.
0.53.0 / 2015-12-14

@@ -399,5 +425,5 @@ ===================

* Added basic [block mixins](http://learnboost.github.io/stylus/docs/mixins.html#block-mixins) (`+foo`) with block interpolation (`block`), #1223.
* Added [`selector()` bif](http://learnboost.github.io/stylus/docs/selectors.html#selector-bif), #1249.
* Added [hash interpolation to blocks](http://learnboost.github.io/stylus/docs/hashes.html#interpolation), #1202.
* Added basic [block mixins](http://stylus-lang.com/docs/mixins.html#block-mixins) (`+foo`) with block interpolation (`block`), #1223.
* Added [`selector()` bif](http://stylus-lang.com/docs/selectors.html#selector-bif), #1249.
* Added [hash interpolation to blocks](http://stylus-lang.com/docs/hashes.html#interpolation), #1202.
* Fixed parent reference in root context from returning `&`.

@@ -404,0 +430,0 @@ * Fixed bug with double writing media blocks, 1ed44a81

@@ -11,2 +11,3 @@ var nodes = require('../nodes');

module.exports = function currentMedia(){
var self = this;
return new nodes.String(lookForMedia(this.closestBlock.node) || '');

@@ -16,2 +17,3 @@

if ('media' == node.nodeName) {
node.val = self.visit(node.val);
return node.toString();

@@ -18,0 +20,0 @@ } else if (node.block.parent.node) {

@@ -9,9 +9,13 @@ var utils = require('../utils')

* @param {Expression} expr
* @param {Boolean} [global]
* @api public
*/
module.exports = function define(name, expr){
module.exports = function define(name, expr, global){
utils.assertType(name, 'string', 'name');
expr = utils.unwrap(expr);
var scope = this.currentScope;
if (global && global.toBoolean().isTrue) {
scope = this.global.scope;
}
var node = new nodes.Ident(name.val, expr);

@@ -18,0 +22,0 @@ scope.add(node);

@@ -58,2 +58,3 @@

exports.substr = require('./substr');
exports.slice = require('./slice');
exports.tan = require('./tan');

@@ -60,0 +61,0 @@ exports.trace = require('./trace');

38

lib/functions/match.js
var utils = require('../utils')
, nodes = require('../nodes');
var VALID_FLAGS = 'igm';
/**
* Test if `val` matches the given `pattern`.
* retrieves the matches when matching a `val`(string)
* against a `pattern`(regular expression).
*
* Examples:
* $regex = '^(height|width)?([<>=]{1,})(.*)'
*
* match('^foo(bar)?', foo)
* match('^foo(bar)?', foobar)
* match('^foo(bar)?', 'foo')
* match('^foo(bar)?', 'foobar')
* // => true
* match($regex,'height>=sm')
* // => ('height>=sm' 'height' '>=' 'sm')
* // => also truthy
*
* match('^foo(bar)?', 'bar')
* // => false
* match($regex, 'lorem ipsum')
* // => null
*
* @param {String} pattern
* @param {String|Ident} val
* @return {Boolean}
* @param {String|Ident} [flags='']
* @return {String|Null}
* @api public
*/
module.exports = function match(pattern, val){
module.exports = function match(pattern, val, flags){
utils.assertType(pattern, 'string', 'pattern');
utils.assertString(val, 'val');
var re = new RegExp(pattern.val);
return new nodes.Boolean(re.test(val.string));
var re = new RegExp(pattern.val, validateFlags(flags) ? flags.string : '');
return val.string.match(re);
};
function validateFlags(flags) {
flags = flags && flags.string;
if (flags) {
return flags.split('').every(function(flag) {
return ~VALID_FLAGS.indexOf(flag);
});
}
return false;
}

@@ -38,2 +38,10 @@

/**
* Supported encoding types
*/
var encodingTypes = {
BASE_64: 'base64',
UTF8: 'charset=utf-8'
}
/**
* Return a url() function with the given `options`.

@@ -65,5 +73,12 @@ *

function fn(url){
/**
* @param {object} url - The path to the image you want to encode.
* @param {object} enc - The encoding for the image. Defaults to base64, the
* other valid option is `utf8`.
*/
function fn(url, enc){
// Compile the url
var compiler = new Compiler(url);
var compiler = new Compiler(url)
, encoding = encodingTypes.BASE_64;
compiler.isURL = true;

@@ -81,3 +96,4 @@ url = url.nodes.map(function(node){

, paths = _paths.concat(this.paths)
, buf;
, buf
, result;

@@ -109,4 +125,11 @@ // Not supported

if (enc && 'utf8' == enc.first.val.toLowerCase()) {
encoding = encodingTypes.UTF8;
result = encodeURI(buf.toString('utf8'));
} else {
result = buf.toString(encoding) + hash;
}
// Encode
return new nodes.Literal('url("data:' + mime + ';base64,' + buf.toString('base64') + hash + '")');
return new nodes.Literal('url("data:' + mime + ';' + encoding + ',' + result + '")');
};

@@ -113,0 +136,0 @@

@@ -84,3 +84,3 @@

.replace(/\\ *\n/g, '\r')
.replace(/([,(:](?!\/\/[^ ])) *(?:\/\/[^\n]*)?\n\s*/g, comment)
.replace(/([,(:](?!\/\/[^ ])) *(?:\/\/[^\n]*|\/\*.*?\*\/)?\n\s*/g, comment)
.replace(/\s*\n[ \t]*([,)])/g, comment);

@@ -87,0 +87,0 @@ };

@@ -177,3 +177,3 @@

case 'is a':
if ('string' == right.nodeName) {
if ('string' == right.first.nodeName) {
return nodes.Boolean(this.nodeName == right.val);

@@ -180,0 +180,0 @@ } else {

@@ -1636,3 +1636,4 @@ /*!

var defined = new nodes.BinOp('is defined', node)
, lookup = new nodes.Ident(name);
, lookup = new nodes.Expression;
lookup.push(new nodes.Ident(name));
node = new nodes.Ternary(defined, lookup, node);

@@ -1639,0 +1640,0 @@ break;

@@ -129,12 +129,13 @@

Renderer.prototype.deps = function(filename){
if (filename) this.options.filename = filename;
var opts = utils.merge({ cache: false }, this.options);
if (filename) opts.filename = filename;
var DepsResolver = require('./visitor/deps-resolver')
, parser = new Parser(this.str, this.options);
, parser = new Parser(this.str, opts);
try {
nodes.filename = this.options.filename;
nodes.filename = opts.filename;
// parse
var ast = parser.parse()
, resolver = new DepsResolver(ast, this.options);
, resolver = new DepsResolver(ast, opts);

@@ -146,3 +147,3 @@ // resolve dependencies

options.input = err.input || this.str;
options.filename = err.filename || this.options.filename;
options.filename = err.filename || opts.filename;
options.lineno = err.lineno || parser.lexer.lineno;

@@ -149,0 +150,0 @@ options.column = err.column || parser.lexer.column;

@@ -59,2 +59,3 @@ /*!

|| this.relative()
|| this.initial()
|| this.escaped()

@@ -99,2 +100,14 @@ || this.parent()

/**
* '~/'
*/
SelectorParser.prototype.initial = function() {
if (!this.pos && '~' == this.str[0] && '/' == this.str[1]) {
this.nested = false;
this.skip(2);
return this.stack[0];
}
};
/**
* '\' ('&' | '^')

@@ -119,2 +132,4 @@ */

if ('&' == this.str[0]) {
this.nested = false;
if (!this.pos && (!this.stack.length || this.raw)) {

@@ -129,3 +144,2 @@ var i = 0;

this.nested = false;
this.skip(1);

@@ -184,2 +198,3 @@ if (!this.raw)

, ret;
if ('..' == this.str.slice(0, 2)) {

@@ -203,4 +218,6 @@ this.skip(2);

selector.raw = true;
return selector.parse().val.trim();
}, this).join(' ');
return selector.parse();
}, this).map(function(selector) {
return (selector.nested ? ' ' : '') + selector.val;
}).join('').trim();
}

@@ -207,0 +224,0 @@ } else {

@@ -465,3 +465,3 @@

parents.push(str);
child = new Parser(buf[i], parents, parts).parse();
var child = new Parser(buf[i], parents, parts).parse();

@@ -468,0 +468,0 @@ if (child.nested) {

@@ -33,3 +33,2 @@ /*!

this.spaces = options['indent spaces'] || 2;
this.includeCSS = options['include css'];
this.indents = 1;

@@ -36,0 +35,0 @@ Visitor.call(this, root);

@@ -63,2 +63,6 @@

var str = fs.readFileSync(file, 'utf8');
// shortcut for empty files
if (!str.trim()) return nodes.null;
if (literal) {

@@ -80,3 +84,3 @@ literal = new nodes.Literal(str.replace(/\r\n?/g, '\n'));

if (this.includeCSS && this.resolveURL) {
if (literal && this.includeCSS && this.resolveURL) {
this.warn('ParseError: ' + file + ':' + line + ':' + column + '. This file included as-is');

@@ -218,6 +222,16 @@ return literal;

// expose url function
scope.add(new nodes.Ident(
'embedurl',
new nodes.Function('embedurl', require('../functions/url')({
limit: false
}))
));
// user-defined globals
var globals = this.globals;
Object.keys(globals).forEach(function(name){
scope.add(new nodes.Ident(name, globals[name]));
var val = globals[name];
if (!val.nodeName) val = new nodes.Literal(val);
scope.add(new nodes.Ident(name, val));
});

@@ -983,3 +997,3 @@ };

if (arg) {
arg.isEmpty ? args.nodes[i - 1] = node.val : node.val = arg;
arg.isEmpty ? args.nodes[i - 1] = this.visit(node) : node.val = arg;
} else {

@@ -996,3 +1010,3 @@ args.push(node.val);

scope.add(node);
});
}, this);

@@ -999,0 +1013,0 @@ // mixin block

@@ -43,2 +43,3 @@ /*!

this.basename = basename(this.dest);
this.dest = dirname(this.dest);
} else {

@@ -45,0 +46,0 @@ this.basename = basename(this.filename, extname(this.filename)) + '.css';

{
"name": "stylus",
"description": "Robust, expressive, and feature-rich CSS superset",
"version": "0.53.0",
"version": "0.54.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",

@@ -28,3 +28,3 @@ "keywords": [

"prepublish": "npm prune",
"test": "mocha test/ test/middleware/ --require should --bail --reporter dot",
"test": "mocha test/ test/middleware/ --require should --bail --check-leaks --reporter dot",
"test-cov": "mocha test/ test/middleware/ --require should --bail --reporter html-cov > coverage.html"

@@ -41,3 +41,3 @@ },

"devDependencies": {
"should": "2.x",
"should": "8.x",
"mocha": "*",

@@ -44,0 +44,0 @@ "jscoverage": "0.3.8"

@@ -11,2 +11,9 @@ # Stylus [![Build Status](https://travis-ci.org/stylus/stylus.svg?branch=master)](https://travis-ci.org/stylus/stylus)

## Basic Usage
Watch and compile a stylus file from command line with
```bash
stylus -w style.styl -o style.css
```
You can also [try all stylus features on stylus-lang.com](http://stylus-lang.com/try.html), build something with stylus on [codepen](http://codepen.io) or integrate stylus with [gulp](http://gulpjs.com/) using [gulp-stylus](https://www.npmjs.com/package/gulp-stylus) or [gulp-accord](https://www.npmjs.com/package/gulp-accord).
### Example

@@ -13,0 +20,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc