UNPKG

postcss-nth-list

Version:

A work in progress postcss module for picking items from a 'varible list'.

14 lines (11 loc) 427 B
var postcss = require('postcss'); module.exports = postcss.plugin('postcss-nth-list', function (opts) { return function (css, result) { css.replaceValues(/nth\((.+),\s*([0-9]+)\)/, {fast: 'nth('}, function (string) { var match = string.match(/nth\((.+),\s*([0-9]+)/); var list = match[1].split(" "); var index = match[2]; return list[index]; }); }; });