sast
sast copied to clipboard
.stringify() parses curly braces for SASS
In stringify.js, mods.block is hardcoded to curlies.
If the argument signature is changed to:
const stringify = (node, options = { depth: 0, syntax: 'css' }) => {
and the mod declaration moved inside of the stringify closure, with one additional change made to buffer = node.children.reduce() so that it is
buffer = node.children.reduce(
(buff, child) =>
buff.concat(
stringify(child, { depth: options.depth + 1, syntax: options.syntax }), // <-- PASSING OPTS HERE
),
[],
)
Then we change mods.block
const mods = {
'block': (options.syntax != 'sass') && curlies,
// etc
}
The issue is resolved.
const sassAST = sast.parse(mockSASS, {syntax: 'sass'})
sast.stringify(sassAST, {syntax: 'sass'})
I can submit PR for this tomorrow.