stylus.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*!
  2. * Stylus
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var Renderer = require('./renderer')
  10. , nodes = require('./nodes')
  11. , utils = require('./utils');
  12. /**
  13. * Export render as the module.
  14. */
  15. exports = module.exports = render;
  16. /**
  17. * Library version.
  18. */
  19. exports.version = require('../package').version;
  20. /**
  21. * Expose nodes.
  22. */
  23. exports.nodes = nodes;
  24. /**
  25. * Expose BIFs.
  26. */
  27. exports.functions = require('./functions');
  28. /**
  29. * Expose utils.
  30. */
  31. exports.utils = require('./utils');
  32. /**
  33. * Expose middleware.
  34. */
  35. exports.middleware = require('./middleware');
  36. /**
  37. * Expose constructors.
  38. */
  39. exports.Visitor = require('./visitor');
  40. exports.Parser = require('./parser');
  41. exports.Evaluator = require('./visitor/evaluator');
  42. exports.Normalizer = require('./visitor/normalizer');
  43. exports.Compiler = require('./visitor/compiler');
  44. /**
  45. * Convert the given `css` to `stylus` source.
  46. *
  47. * @param {String} css
  48. * @return {String}
  49. * @api public
  50. */
  51. exports.convertCSS = require('./convert/css');
  52. /**
  53. * Render the given `str` with `options` and callback `fn(err, css)`.
  54. *
  55. * @param {String} str
  56. * @param {Object|Function} options
  57. * @param {Function} fn
  58. * @api public
  59. */
  60. exports.render = function(str, options, fn){
  61. if ('function' == typeof options) fn = options, options = {};
  62. return new Renderer(str, options).render(fn);
  63. };
  64. /**
  65. * Return a new `Renderer` for the given `str` and `options`.
  66. *
  67. * @param {String} str
  68. * @param {Object} options
  69. * @return {Renderer}
  70. * @api public
  71. */
  72. function render(str, options) {
  73. return new Renderer(str, options);
  74. }
  75. /**
  76. * Expose optional functions.
  77. */
  78. exports.url = require('./functions/url');
  79. exports.resolver = require('./functions/resolver');