How to use the stylus/lib/parser.js function in stylus

To help you get started, we’ve selected a few stylus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github txs1992 / stylus-converter / src / index.js View on Github external
export function converter(result, options = {
  quote: `'`,
  conver: 'sass',
  autoprefixer: true
}, globalVariableList = []) {
  if (options.isSignComment) result = result.replace(/\/\/\s(.*)/g, '/* !#sign#! $1 */')

  // Add semicolons to properties with inline comments to ensure that they are parsed correctly
  result = result.replace(/^( *)(\S(.+?))( *)(\/\*.*\*\/)$/gm, '$1$2;$4$5');

  if (typeof result !== 'string') return result
  const ast = new Parser(result).parse()
  // 开发时查看 ast 对象。
  console.log(JSON.stringify(ast))
  const text = visitor(ast, options, globalVariableList)
  // Convert special multiline comments to single-line comments
  return text.replace(/\/\*\s!#sign#!\s(.*)\s\*\//g, '// $1')
}
github txs1992 / stylus-converter / src / index.js View on Github external
export function parse(result) {
  return new Parser(result).parse()
}