• Stars
    star
    110
  • Rank 315,744 (Top 7 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library to parse/stringify SCSS

SCSS Parser

Build Status Dependabot Status NPM version

Getting Started

let { parse, stringify } = require('scss-parser')

// Create an AST from a string of SCSS
let ast = parse('.hello { color: $red; }')
// Modify the AST (see below for a better way to do this)
ast.value[0].value[0].value[0].value[0].value = 'world'
// Convert the modified AST back to SCSS
let scss = stringify(ast) // .world { color: $red; }

Traversal

For an easy way to traverse/modify the generated AST, check out QueryAST

let { parse, stringify } = require('scss-parser')
let createQueryWrapper = require('query-ast')

// Create an AST
let ast = parse('.hello { color: red; } .world { color: blue; }')
// Create a function to traverse/modify the AST
let $ = createQueryWrapper(ast)
// Make some modifications
$('rule').eq(1).remove()
// Convert the modified AST back to a string
let scss = stringify($().get(0))

Running tests

Clone the repository, then:

npm install
# requires node >= 5.0.0
npm test

License

Copyright (c) 2016, salesforce.com, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

More Repositories

1

design-system

Salesforce Lightning Design System
JavaScript
3,503
star
2

theo

Theo is a an abstraction for transforming and formatting Design Tokens
JavaScript
1,932
star
3

design-system-ui-kit

Lightning Design System UI Kit
377
star
4

design-system-starter-kit

Rapid prototyping environment using the Salesforce Lightning Design System
HTML
347
star
5

sass-deprecate

Let Sass warn you about the pieces of your UI that are deprecated, providing a clear upgrade path for developers
JavaScript
270
star
6

blender

DEPRECATED: this project isn't maintained anymore.
JavaScript
71
star
7

design-system-ios

Salesforce Lightning Design Tokens for iOS
Swift
66
star
8

query-ast

A library to traverse/modify an AST
JavaScript
63
star
9

dnd-a11y-patterns

Examples of accessible drag-and-drop patterns
JavaScript
49
star
10

design-system-ui-kit-data

A collection of fictitious Salesforce data for use as Sketch custom data. Use this info to populate designs created from the Lightning Design System UI Kit.
47
star
11

theo-example

Example project for integrating Design Properties using Theo
JavaScript
29
star
12

design-system-android

Java
24
star
13

gulp-theo

Gulp-theo is a plugin that transforms and formats Design Tokens
JavaScript
18
star
14

portion-control

Badge to quickly communicate project values
JavaScript
11
star
15

instant-vrt

Module for running vrt
JavaScript
8
star
16

design-system-ui-kit-framerx

Public code. Not supported by Salesforce
TypeScript
7
star
17

design-system-bower

7
star
18

design-tokens

DEPRECATED repository - Salesforce Design Tokens
JavaScript
6
star
19

gdm

Git Dependency Manager
JavaScript
6
star
20

design-system-parser

JavaScript
5
star
21

design-system-markup

JavaScript
5
star
22

design-system-sketch

A plugin for interacting with the Lightning Design System in Sketch
4
star
23

lightning-design-system-linter

Lightning Design System design validation directly in Sketch
TypeScript
4
star
24

stylelint-config-slds

Lightning Design System shareable config for stylelint
JavaScript
3
star
25

design-system-windows

C#
2
star
26

heroku-buildpack-nginx

Shell
2
star
27

df19-talk-design-data-science

Dreamforce 19 talk: Improving Design with Data Science files
Jupyter Notebook
1
star
28

test-drive-brown-bag

tdd fun for all
JavaScript
1
star
29

design-system-compiler

Sass Compiler for the design system
JavaScript
1
star
30

scss-inline-imports

A library to inline SCSS @import statements
JavaScript
1
star